Skip to content

feat(workspace): support percent‐escaped Base64 with special characters in code= URL parameter #6023

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

Conversation

CoveMB
Copy link
Contributor

@CoveMB CoveMB commented May 13, 2025

Desciption

This change improves how the Workspace plugin decodes the code= fragment passed via the URL, allowing it to correctly handle any percent‐escaped Base64 payload—including strings containing non‐ASCII or URL-unsafe characters. Previously the code was decoded inline with decodeURIComponent + atob, which could break on certain edge cases.

Changes

  • Added new decodePercentEscapedBase64 helper function
  • Refactored the loadWorkspacePreset('code-template') flow in libs/remix-ui/workspace/src/lib/actions/workspace.ts to call decodePercentEscapedBase64(params.code) instead of inline atob(decodeURIComponent(params.code)

Why

In OpenZeppelin's wizard we recently added support for unicode characters
And modified the encoding of the code parameter to be sent to remix to support special characters

How to test

  • run remix locally
  • open the following url which contain the encoding of the following contract (notice the special characters)
contract CMyToken is ERC20, ERC20Permit {
    constructor()
        ERC20(unicode"ḉMyToken🌻", "MTK")
        ERC20Permit(unicode"ḉMyToken🌻")
    {}
}

http://localhost:8080/?#code=Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVAovLyBDb21wYXRpYmxlIHdpdGggT3BlblplcHBlbGluIENvbnRyYWN0cyBeNS4wLjAKcHJhZ21hIHNvbGlkaXR5IF4wLjguMjc7CgppbXBvcnQge0VSQzIwfSBmcm9tICJAb3BlbnplcHBlbGluL2NvbnRyYWN0c0A1LjMuMC90b2tlbi9FUkMyMC9FUkMyMC5zb2wiOwppbXBvcnQge0VSQzIwUGVybWl0fSBmcm9tICJAb3BlbnplcHBlbGluL2NvbnRyYWN0c0A1LjMuMC90b2tlbi9FUkMyMC9leHRlbnNpb25zL0VSQzIwUGVybWl0LnNvbCI7Cgpjb250cmFjdCBDTXlUb2tlbiBpcyBFUkMyMCwgRVJDMjBQZXJtaXQgewogICAgY29uc3RydWN0b3IoKQogICAgICAgIEVSQzIwKHVuaWNvZGUi4biJTXlUb2tlbvCfjLsiLCAiTVRLIikKICAgICAgICBFUkMyMFBlcm1pdCh1bmljb2RlIuG4iU15VG9rZW7wn4y7IikKICAgIHt9Cn0K&lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.30+commit.73712a01.js

Next

please advise where could I add related tests (I thought of adding 2e2 tests in apps/remix-ide-e2e/src/tests/url.test.ts but it seem they are disabled?

Copy link

netlify bot commented May 13, 2025

👷 Deploy request for remixproject pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit fda7237

@Aniket-Engg Aniket-Engg force-pushed the allow-special-unicode-character-url-code-param branch from 1e07c85 to fda7237 Compare May 19, 2025 08:39
Copy link
Collaborator

@Aniket-Engg Aniket-Engg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionality wise looks fine

@Aniket-Engg Aniket-Engg merged commit 57dead2 into ethereum:master May 19, 2025
24 of 27 checks passed
@Aniket-Engg
Copy link
Collaborator

please advise where could I add related tests (I thought of adding 2e2 tests in apps/remix-ide-e2e/src/tests/url.test.ts but it seem they are disabled?

@CoveMB Not all tests are disabled there. You can add the e2e in url.test.ts in a different PR

@CoveMB
Copy link
Contributor Author

CoveMB commented May 21, 2025

Thanks, will do ✨

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