summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorJani Heikkinen <jani.heikkinen@theqtcompany.com>2016-01-21 04:27:06 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-01-21 04:27:06 +0000
commit7b2fb038ae4b8b9231ae989ad309b6eca107a858 (patch)
tree04001416e9589b7e79a6a5b1490e7eaabc22e82a /src/corelib/codecs
parent9c0de96454570aec3fe88ba6b5d7c61b666b5753 (diff)
parent8f569c740a91b98365dcdaee2444038ce4957a76 (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/qutfcodec.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index a64b3d167e..476990fb7a 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -363,6 +363,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::Converte
// main body, stateless decoding
res = 0;
const uchar *nextAscii = src;
+ const uchar *start = src;
while (res >= 0 && src < end) {
if (src >= nextAscii && simdDecodeAscii(dst, nextAscii, src, end))
break;
@@ -371,9 +372,11 @@ QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::Converte
res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(ch, dst, src, end);
if (!headerdone && res >= 0) {
headerdone = true;
- // eat the UTF-8 BOM
- if (dst[-1] == 0xfeff)
- --dst;
+ if (src == start + 3) { // 3 == sizeof(utf8-bom)
+ // eat the UTF-8 BOM (it can only appear at the beginning of the string).
+ if (dst[-1] == 0xfeff)
+ --dst;
+ }
}
if (res == QUtf8BaseTraits::Error) {
res = 0;