Fixed error with Poco::UTF8Encoding::isLegal (wrong result on illegal sequence "\xED\x20\xA8").

This commit is contained in:
Alexey Milovidov 2016-10-29 20:27:28 +03:00
parent 5df7f69b08
commit 95590d620e

View File

@ -224,23 +224,23 @@ bool UTF8Encoding::isLegal(const unsigned char *bytes, int length)
case 3: case 3:
if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 2: case 2:
if ((a = (*--srcptr)) > 0xBF) return false; a = (*--srcptr);
switch (*bytes) switch (*bytes)
{ {
case 0xE0: case 0xE0:
if (a < 0xA0) return false; if (a < 0xA0 || a > 0xBF) return false;
break; break;
case 0xED: case 0xED:
if (a > 0x9F) return false; if (a < 0x80 || a > 0x9F) return false;
break; break;
case 0xF0: case 0xF0:
if (a < 0x90) return false; if (a < 0x90 || a > 0xBF) return false;
break; break;
case 0xF4: case 0xF4:
if (a > 0x8F) return false; if (a < 0x80 || a > 0x8F) return false;
break; break;
default: default:
if (a < 0x80) return false; if (a < 0x80 || a > 0xBF) return false;
} }
case 1: case 1:
if (*bytes >= 0x80 && *bytes < 0xC2) return false; if (*bytes >= 0x80 && *bytes < 0xC2) return false;