-
Notifications
You must be signed in to change notification settings - Fork 492
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
Pashov L-05 add more special characters to escape #374
Conversation
@@ -503,6 +503,10 @@ library Descriptor { | |||
} | |||
} | |||
|
|||
function isSpecialCharacter(bytes1 b) private pure returns (bool) { | |||
return b == '"' || b == "\u000c" || b == "\n" || b == "\r" || b == "\t"; |
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.
am i mad? surely \u000c
is longer than a single byte?
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.
I had exactly the same thought! Turns out it gets properly escaped to 1 byte:
pragma solidity ^0.8.0;
contract RandomTest {
function stringToBytes32() public pure returns (uint256 length) {
string memory source = "\u000c";
bytes memory tempEmptyStringTest = bytes(source);
return tempEmptyStringTest.length;
}
}
If you test this out in Remix the return value is 1 :)
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.
wild, thanks for the poc :)
Related Issue
Pashov L-05 https://github.com/PashovAuditGroup/Uniswap_October_MERGED/issues/9
Special characters not escaped can produce invalid JSON
Description of changes
check form feeds, new lines, carriage returns, or tabs to escape