diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2010-11-04 07:47:08 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2010-11-04 08:08:26 (GMT) |
commit | 15a7626480b64d85992bed819fe6052e0c5c8fa9 (patch) | |
tree | 171cbdf64fc620b7b0a7206205b4243130e44859 /qmake/project.cpp | |
parent | b59b90678d061bf5935a47385be7f2a31e8eb935 (diff) | |
download | Qt-15a7626480b64d85992bed819fe6052e0c5c8fa9.zip Qt-15a7626480b64d85992bed819fe6052e0c5c8fa9.tar.gz Qt-15a7626480b64d85992bed819fe6052e0c5c8fa9.tar.bz2 |
Make qmake to pass all UTF-8 characters unchanged through parser.
QMakeProject::parse() calls QString::simplified(), which assumes any
byte 0xA0 in multibyte UTF-8 characters is a space character (0x00A0 is
unicode character NBSP [non-breaking space]) and replaces those bytes
with regular space, corrupting the UTF-8 string.
Fixed by temporarily changing all 0xA0 bytes in parser input to another
non-space character 0x01A0. This is safe replacement as qmake doesn't
accept unicode .pro files, so there should never be actual NBSP or the
replacement 0x01A0 characters in a valid .pro file.
Note that there are a couple of more uses of QString::simplified() in
qmake, but those do not deal with strings that need to be UTF-8
compatible as far as I can tell, so no need to touch them.
Task-number: QTBUG-14357
Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'qmake/project.cpp')
-rw-r--r-- | qmake/project.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 7351d1a..5f5745a 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -677,7 +677,23 @@ QMakeProject::reset() bool QMakeProject::parse(const QString &t, QMap<QString, QStringList> &place, int numLines) { - QString s = t.simplified(); + // To preserve the integrity of any UTF-8 characters in .pro file, temporarily replace the + // non-breaking space (0xA0) characters with another non-space character, so that + // QString::simplified() call will not replace it with space. + // Note: There won't be any two byte characters in .pro files, so 0x10A0 should be a safe + // replacement character. + static QChar nbsp(0xA0); + static QChar nbspFix(0x01A0); + QString s; + if (t.indexOf(nbsp) != -1) { + s = t; + s.replace(nbsp, nbspFix); + s = s.simplified(); + s.replace(nbspFix, nbsp); + } else { + s = t.simplified(); + } + int hash_mark = s.indexOf("#"); if(hash_mark != -1) //good bye comments s = s.left(hash_mark); |