Skip to content
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

Merged
merged 5 commits into from
Oct 28, 2024
Merged

Conversation

dianakocsis
Copy link
Contributor

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

@@ -503,6 +503,10 @@ library Descriptor {
}
}

function isSpecialCharacter(bytes1 b) private pure returns (bool) {
return b == '"' || b == "\u000c" || b == "\n" || b == "\r" || b == "\t";
Copy link
Contributor

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?

Copy link

@djb15 djb15 Oct 24, 2024

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 :)

Copy link
Contributor

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 :)

hensha256
hensha256 previously approved these changes Oct 24, 2024
@dianakocsis dianakocsis merged commit 825b20a into main Oct 28, 2024
3 checks passed
@dianakocsis dianakocsis deleted the pashov-l05 branch October 28, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants