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

fix: decode URL-encoded characters #3565

Merged
merged 1 commit into from
Apr 17, 2023
Merged

fix: decode URL-encoded characters #3565

merged 1 commit into from
Apr 17, 2023

Conversation

neutiyoo
Copy link
Contributor

Description

This PR fixes the URL decoding issue with base64 encoded contract codes.

For example, bWFwcGluZyhhZGRyZXNzID0+IHVpbnQyNTYpIHB1YmxpYyBmb287 is base64 encoded value of mapping(address => uint256) public foo;.

+ is URL encoded to %2B causing the following error in the Remix IDE:

DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

The decodeURIComponent function is used to decode any URL-encoded characters in the params.code string before passing it to the atob function. This is necessary because atob expects a string that has already been encoded in base64 format and does not handle URL-encoded characters. By applying decodeURIComponent first, you ensure that the atob function will be able to properly decode the base64-encoded string.

NOTE:
The set of characters used in Base64 encoding includes the 26 uppercase letters of the alphabet (A-Z), the 26 lowercase letters (a-z), the 10 digits (0-9), and two additional characters: the plus sign (+) and the forward slash (/). Additionally, the equals sign (=) is used as a padding character to make the length of the output a multiple of 4.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for remixproject ready!

Name Link
🔨 Latest commit e155252
🔍 Latest deploy log https://app.netlify.com/sites/remixproject/deploys/643d472cfc5791000713cbcf
😎 Deploy Preview https://deploy-preview-3565--remixproject.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Aniket-Engg Aniket-Engg requested a review from yann300 April 5, 2023 13:10
@Aniket-Engg Aniket-Engg self-requested a review April 17, 2023 13:18
@Aniket-Engg Aniket-Engg merged commit 44ef80b into ethereum:master Apr 17, 2023
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.

2 participants