зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1033983
- Bypass the UTF conversion of null char if it's not the last one. r=chucklee
This commit is contained in:
Родитель
b47a5e41e8
Коммит
6788da60da
|
@ -169,6 +169,13 @@ void LossyConvertUTF8toUTF16(const char* aInput, uint32_t aLength, nsAString& aO
|
||||||
uint32_t j = 0;
|
uint32_t j = 0;
|
||||||
for (uint32_t i = 0; i < srclen; i++, j++) {
|
for (uint32_t i = 0; i < srclen; i++, j++) {
|
||||||
uint32_t v = uint32_t(src[i]);
|
uint32_t v = uint32_t(src[i]);
|
||||||
|
if (v == uint32_t('\0') && i < srclen - 1) {
|
||||||
|
// If the leading byte is '\0' and it's not the last byte,
|
||||||
|
// just ignore it to prevent from being truncated. This could
|
||||||
|
// be caused by |convertToBytes| (e.g. \x00 would be converted to '\0')
|
||||||
|
j--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!(v & 0x80)) {
|
if (!(v & 0x80)) {
|
||||||
// ASCII code unit. Simple copy.
|
// ASCII code unit. Simple copy.
|
||||||
dst[j] = char16_t(v);
|
dst[j] = char16_t(v);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче