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-08 09:51:41 (GMT) |
commit | e5345aa59d6573abb39b50285b63aafcddd9f13b (patch) | |
tree | c209a5390c893dd1ab7fa37335fa1ef61c3e4b95 /qmake | |
parent | e00354a40db497fe35fde7055521c2246e7a3e7c (diff) | |
download | Qt-e5345aa59d6573abb39b50285b63aafcddd9f13b.zip Qt-e5345aa59d6573abb39b50285b63aafcddd9f13b.tar.gz Qt-e5345aa59d6573abb39b50285b63aafcddd9f13b.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.
Cherry picked to 4.7 branch from master branch as part of QTBUG-15068,
original commit: 15a7626480b64d85992bed819fe6052e0c5c8fa9
Task-number: QTBUG-15068
Task-number: QTBUG-14357
Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'qmake')
-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 427bea3..fe08b7b 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); |