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

feat: add Network URL non-ascii -> punycode warning #12813

Merged
merged 14 commits into from
Jan 14, 2025

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Dec 20, 2024

Description

Similar to the extension, we want to warn the user if the URL has non-ASCII characters. Inline alerts are not supported on mobile, so we display the new alert as a banner.

Notes:

  • existing Network URL logic removes the path with hideKeyFromUrl
  • punycode is deprecated, however, the url library does not seem to parse the url into its punycode encoded version in react-native. It is tricky as the url does parse into its punycode version in node.js, jest tests

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2365
Related to: MetaMask/metamask-extension#29490 (fixes isValidASCIIURL to include path check in extension)

Manual testing steps

Test switching to a custom network

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@digiwand digiwand requested a review from a team as a code owner December 20, 2024 16:15
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Dec 20, 2024
@digiwand digiwand added the Run Smoke E2E Triggers smoke e2e on Bitrise label Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: b51117b
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/60aea724-ad25-4a52-a37e-4a1f67c759c3

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

app/util/url/index.ts Outdated Show resolved Hide resolved
@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jan 7, 2025
Copy link
Contributor

github-actions bot commented Jan 7, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 3e2aac9
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c850e466-34be-40f9-a878-f3e9ae77b565

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

jpuri
jpuri previously approved these changes Jan 8, 2025
Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

Nice work

@digiwand digiwand requested a review from NicholasEllul January 8, 2025 07:59
app/util/url/index.ts Outdated Show resolved Hide resolved
app/util/url/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@NicholasEllul NicholasEllul left a comment

Choose a reason for hiding this comment

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

I notice the following notice in the punycode README: https://github.com/mathiasbynens/punycode.js?tab=readme-ov-file#installation

⚠️ Note that userland modules don't hide core modules. For example, require('punycode') still imports the deprecated core module even if you executed npm install punycode. Use require('punycode/') to import userland modules rather than core modules.

We should double check to ensure we are using the punycode built into node which is soft-deprecated. I notice other files like this one import punycode as the following:

import punycode from 'punycode/punycode';

app/util/url/index.ts Outdated Show resolved Hide resolved
@digiwand digiwand removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Jan 8, 2025
@digiwand digiwand added the Run Smoke E2E Triggers smoke e2e on Bitrise label Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: f891d73
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/fdbd03b6-5fa2-4d78-a480-9b565270bb4d

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jan 13, 2025
Copy link
Contributor

github-actions bot commented Jan 13, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 6f2aef1
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/044480f6-6c19-4214-94cf-a792fabc7bc1

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

Copy link
Contributor

@NicholasEllul NicholasEllul left a comment

Choose a reason for hiding this comment

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

Nice workaround 👍

@digiwand digiwand enabled auto-merge January 14, 2025 16:26
@digiwand digiwand added this pull request to the merge queue Jan 14, 2025
Merged via the queue into main with commit 52a481d Jan 14, 2025
40 of 41 checks passed
@digiwand digiwand deleted the feat-display-network-url-punycode-encoding branch January 14, 2025 18:21
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2025
@metamaskbot metamaskbot added the release-7.39.0 Issue or pull request that will be included in release 7.39.0 label Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.39.0 Issue or pull request that will be included in release 7.39.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants