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(settings): fixed two IPFS gateway issues #19700

Merged
merged 6 commits into from
Aug 23, 2023
Merged

Conversation

HowardBraham
Copy link
Contributor

Explanation

@github-actions
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.

@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch 2 times, most recently from 5158666 to e684692 Compare June 21, 2023 05:32
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #19700 (777c5bf) into develop (e02f597) will increase coverage by 0.33%.
The diff coverage is 81.94%.

❗ Current head 777c5bf differs from pull request most recent head a82362e. Consider uploading reports for the commit a82362e to get more accurate results

@@             Coverage Diff             @@
##           develop   #19700      +/-   ##
===========================================
+ Coverage    68.84%   69.17%   +0.33%     
===========================================
  Files          993      994       +1     
  Lines        38258    38271      +13     
  Branches     10248    10251       +3     
===========================================
+ Hits         26338    26472     +134     
+ Misses       11920    11799     -121     
Files Changed Coverage Δ
ui/pages/keychains/reveal-seed.js 98.75% <ø> (+1.22%) ⬆️
...c-method-middleware/handlers/add-ethereum-chain.js 9.15% <21.43%> (+0.49%) ⬆️
app/scripts/lib/util.ts 90.62% <92.31%> (+34.55%) ⬆️
...ttings/networks-tab/networks-form/networks-form.js 81.82% <100.00%> (-0.06%) ⬇️
...es/settings/security-tab/security-tab.component.js 100.00% <100.00%> (+22.83%) ⬆️

... and 6 files with indirect coverage changes

@metamaskbot

This comment was marked as outdated.

@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch 2 times, most recently from bc924d8 to 74e3b25 Compare July 18, 2023 19:45
@socket-security
Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: [email protected]

@metamaskbot

This comment was marked as outdated.

@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch from 4bba7de to 22193b8 Compare July 18, 2023 20:53
@HowardBraham HowardBraham marked this pull request as ready for review July 18, 2023 20:55
@HowardBraham HowardBraham requested a review from a team as a code owner July 18, 2023 20:55
@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch from 22193b8 to b7713c5 Compare July 18, 2023 20:56
@metamaskbot

This comment was marked as outdated.

@plasmacorral plasmacorral added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) release-10.36.0 Issue or pull request that will be included in release 10.36.0 labels Jul 18, 2023
@HowardBraham HowardBraham requested a review from seaona July 19, 2023 00:52
@HowardBraham HowardBraham mentioned this pull request Jul 25, 2023
8 tasks
Copy link
Member

@NidhiKJha NidhiKJha left a comment

Choose a reason for hiding this comment

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

Valid-url removal is really nice. Though I can still enter IPFS with spaces. We need to validate that?

256262783-ecfb30b2-cc4a-4a3d-80eb-e4853af45734.mov

@HowardBraham
Copy link
Contributor Author

Valid-url removal is really nice. Though I can still enter IPFS with spaces. We need to validate that?

This is a tricky situation, because a URL actually can have a %20 space in it. Is it done a lot? No.

How do we handle this in other places?

@Gudahtt
Copy link
Member

Gudahtt commented Jul 28, 2023

Spaces are allowed in the path, but not the origin. We need to retain some amount of validation here to protect users from accidentally entering invalid URLs.

Elsewhere we validate using the URL constructor. Might that work here?

@HowardBraham
Copy link
Contributor Author

@Gudahtt it's actually already validating through URL

Try new URL('https://a b'), it doesn't produce an error

I'm not actually sure if https://a%20b.com/ is a valid URL, I can't find any clear documentation

@HowardBraham
Copy link
Contributor Author

@Gudahtt @NidhiKJha update... you cannot have a domain name with an encoded space in it because % is not a valid character. But... URL behaves differently in Node and browser!

  • Node new URL('https://a b.com') gives an error
  • Browser new URL('https://a b.com') is fine

Options:

  1. Validate with another package, maybe is-url-http or url
  2. Validate with a regex

Any preferences?

@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch 2 times, most recently from 3484147 to fa9aca7 Compare July 31, 2023 23:00
@HowardBraham HowardBraham force-pushed the fix/two-ipfs-issues branch 2 times, most recently from 2c264d6 to fd24646 Compare August 3, 2023 04:42
@HowardBraham
Copy link
Contributor Author

@Gudahtt @NidhiKJha I fixed the URL validation this way:

const url = new URL(urlString);

if (url.hostname !== decodeURIComponent(url.hostname)) {
  return null; // will happen if there's a %, a space, or other invalid character in the hostname
}

It also now incorporates the changes from #20172

Hopefully should be good to approve and merge now

@metamaskbot

This comment was marked as outdated.

app/scripts/lib/util.ts Outdated Show resolved Hide resolved
@@ -83,27 +83,14 @@ async function addEthereumChainHandler(
);
}

const isLocalhost = (strUrl) => {
Copy link
Contributor

@legobeat legobeat Aug 3, 2023

Choose a reason for hiding this comment

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

Looking this function properly for the first time, it was introduced in #14272.

I find these magic values problematic. What about foo.localhost, localhost.localdomain, self-mapped hostnames, or other loopback addresses like ::1 (i see this in particular regularly tripping people up) or the rest of 127.0.0.0/8? Sure it's usually possible to work around but seems arbitrary and could be a potential cause of hair-pulling in places. So this may need to be revised (possibly even resulting in new user-facing-preference(s)?). Heck, if someone wants to run a block explorer over file:// or some protocol we're not having in mind right now, why not let them?

While the changes in this PR still look like an improvement and resolving that aspect is probably out of scope here, moving this function out to util.ts invites use from other parts of the code, so perhaps it can be moved back and unexported for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I see what you mean... it's better, but not good enough to put in util. I moved the new version of it back to add-ethereum-chain.js.

@metamaskbot
Copy link
Collaborator

Builds ready [5050bc2]
Page Load Metrics (1515 ± 58 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint106189127199
domContentLoaded13611848151412058
load13611848151512058
domInteractive13611848151412058
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -60 Bytes (-0.00%)
  • ui: -120 Bytes (-0.00%)
  • common: -1 KiB (-0.03%)

NidhiKJha
NidhiKJha previously approved these changes Aug 4, 2023
@metamaskbot
Copy link
Collaborator

Builds ready [777c5bf]
Page Load Metrics (1472 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1061911312412
domContentLoaded13251828147210350
load13251828147210350
domInteractive13251828147210350
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -60 Bytes (-0.00%)
  • ui: -47 Bytes (-0.00%)
  • common: -1 KiB (-0.03%)

- adds back in two bugfixes that were originally in #19283
  - fixes #16871
  - fixes #18140

- achieves 100% code coverage for /ui/pages/settings/security-tab
- removes the npm package `valid-url`, which has not been updated in 10 years
@metamaskbot
Copy link
Collaborator

Builds ready [a82362e]
Page Load Metrics (1437 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint107156122126
domContentLoaded1296167014379445
load1296167014379445
domInteractive1296167014379445
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -60 Bytes (-0.00%)
  • ui: -47 Bytes (-0.00%)
  • common: -1 KiB (-0.03%)

@HowardBraham HowardBraham self-assigned this Aug 17, 2023
@HowardBraham HowardBraham merged commit d3d30fd into develop Aug 23, 2023
@HowardBraham HowardBraham deleted the fix/two-ipfs-issues branch August 23, 2023 05:13
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Aug 23, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2023
@metamaskbot metamaskbot added the release-11.1.0 Issue or pull request that will be included in release 11.1.0 label Aug 23, 2023
@Gudahtt Gudahtt removed the release-10.36.0 Issue or pull request that will be included in release 10.36.0 label Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.1.0 Issue or pull request that will be included in release 11.1.0 team-accounts type-bug
Projects
None yet
9 participants