Bläddra i källkod

[Fix] Fix incomplete utf8 sequences handling

tags/2.6
Vsevolod Stakhov 4 år sedan
förälder
incheckning
d3e506655f
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12
    0
      contrib/replxx/src/conversion.cxx

+ 12
- 0
contrib/replxx/src/conversion.cxx Visa fil



while (i < slen && j < dstSize) { while (i < slen && j < dstSize) {
UChar32 uc; UChar32 uc;
auto prev_i = i;
U8_NEXT (sourceStart, i, slen, uc); U8_NEXT (sourceStart, i, slen, uc);


if (uc <= 0) { if (uc <= 0) {
if (U8_IS_LEAD (sourceStart[prev_i])) {
auto lead_byte = sourceStart[prev_i];
auto trailing_bytes = (((uint8_t)(lead_byte)>=0xc2)+
((uint8_t)(lead_byte)>=0xe0)+
((uint8_t)(lead_byte)>=0xf0));

if (trailing_bytes + i > slen) {
return ConversionResult::sourceExhausted;
}
}

/* Replace with 0xFFFD */ /* Replace with 0xFFFD */
uc = 0x0000FFFD; uc = 0x0000FFFD;
} }

Laddar…
Avbryt
Spara