-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly treat utf8-non-encodable yul literals. #11338
Conversation
Should be fixed now. |
lit.value = YulString{member(_node, "value").asString()}; | ||
solAssert(member(_node, "hexValue").isString() || member(_node, "value").isString(), ""); | ||
if (_node.isMember("hexValue")) | ||
lit.value = YulString{util::asString(util::fromHex(member(_node, "hexValue").asString()))}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to also use util::validateUTF8
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, why? Literals can be invalid utf8
Changelog.md
Outdated
@@ -10,6 +10,11 @@ Compiler Features: | |||
|
|||
|
|||
Bugfixes: | |||
* AST: Do not output value of Yul literal if it is not valid utf8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* AST: Do not output value of Yul literal if it is not valid utf8. | |
* AST: Do not output value of Yul literal if it is not a valid utf8 string. |
Rebased and updated changelog. |
@@ -68,6 +68,7 @@ | |||
"src": "79:6:1", | |||
"value": | |||
{ | |||
"hexValue": "37", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value is 7
, but hexValue is 37
?
libyul/AsmJsonConverter.cpp
Outdated
ret["value"] = _node.value.str(); | ||
else | ||
ret["value"] = Json::nullValue; | ||
ret["hexValue"] = util::toHex(util::asBytes(_node.value.str())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's an integer literal, should the hex value go through the byte-string conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you are right, we should only have hexValue
for string literals.
References #11324