mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Validate first byte properly for UTF8
This commit is contained in:
parent
569e0c53f2
commit
6488f7e079
@ -85,11 +85,19 @@ bool validateUTF8(std::string const& _input, size_t& _invalidPosition)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
switch(_input[i] & 0xf0) {
|
switch ((unsigned char)_input[i])
|
||||||
case 0xc0: count = 1; break;
|
{
|
||||||
case 0xe0: count = 2; break;
|
case 0xc0 ... 0xdf:
|
||||||
case 0xf0: count = 3; break;
|
count = 1;
|
||||||
default: break;
|
break;
|
||||||
|
case 0xe0 ... 0xef:
|
||||||
|
count = 2;
|
||||||
|
break;
|
||||||
|
case 0xf0 ... 0xf7:
|
||||||
|
count = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user