Skip to content

Commit 4a1e11c

Browse files
hartworktnyblom
authored andcommitted
Stop unintended re-encoding of author names from UTF-8 to ASCII
To see the bug in action, use an author map with umlauts, e.g. nickname = Hällo Wörld from UTF-8 <mail@example.org> and check "git log" after the conversion. What is happening? QByteArray "author" is first decoded as UTF-8 into a QString. That QString is passed to QByteArray::append(const QString &) which internally encodes the QString to ASCII byte data using QString::toAscii(). "git fast-import" expects UTF-8 input from us, so the original QByteArray with UTF-8 content is just what we need.
1 parent b5c3d3a commit 4a1e11c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/repository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ void Repository::Transaction::commit()
736736
QByteArray s("");
737737
s.append("commit " + branchRef + "\n");
738738
s.append("mark :" + QByteArray::number(mark) + "\n");
739-
s.append("committer " + QString::fromUtf8(author) + " " + QString::number(datetime) + " +0000" + "\n");
739+
s.append("committer " + author + " " + QString::number(datetime).toUtf8() + " +0000" + "\n");
740740
s.append("data " + QString::number(message.length()) + "\n");
741741
s.append(message + "\n");
742742
repository->fastImport.write(s);

0 commit comments

Comments
 (0)