mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix UTF-8 validation for high codepoints (>10000)
This commit is contained in:
parent
17de4a0756
commit
d7e63f23de
@ -40,7 +40,7 @@ bool validateUTF8(std::string const& _input, size_t& _invalidPosition)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
switch(_input[i] & 0xe0) {
|
switch(_input[i] & 0xf0) {
|
||||||
case 0xc0: count = 1; break;
|
case 0xc0: count = 1; break;
|
||||||
case 0xe0: count = 2; break;
|
case 0xe0: count = 2; break;
|
||||||
case 0xf0: count = 3; break;
|
case 0xf0: count = 3; break;
|
||||||
|
@ -2422,6 +2422,16 @@ BOOST_AUTO_TEST_CASE(invalid_utf8_explicit)
|
|||||||
CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed");
|
CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(large_utf8_codepoint)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract C {
|
||||||
|
string s = "\xf0\x9f\xa6\x84";
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_SUCCESS(sourceCode);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(string_index)
|
BOOST_AUTO_TEST_CASE(string_index)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user