refactor: Remove usage of regex for portfolio URLs#8674
Conversation
|
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. |
1ec88e8 to
6cf64a3
Compare
|
E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/98ba3fbe-2b24-456e-9467-f66a49fde58c |
6cf64a3 to
5a03866
Compare
I also noticed this duplicate code but its outside the scope of this change to refactor the duplicated components |
5a03866 to
4d0eb52
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8674 +/- ##
==========================================
+ Coverage 45.98% 46.00% +0.01%
==========================================
Files 1273 1274 +1
Lines 31342 31352 +10
Branches 3213 3215 +2
==========================================
+ Hits 14414 14424 +10
Misses 16079 16079
Partials 849 849 ☔ View full report in Codecov by Sentry. |
|
@NicolasMassart looks like theres a conflict, i'll re-tag you once I rebase! |
5ee86ff to
6dcc34a
Compare
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
|
1 similar comment
|
|
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
|



Description
This PR addresses a few issues related to how we were using regex expressions. In particular, how we were using URLs in regex statements. This is due to the fact that if we use a URL in a regex statement without escaping it, the periods get interpreted as regex wildcard characters.
In this case, it means that URLs such as
https://portfolioxmetamask.iowould be be interpreted by MetaMask as being a valid portfolio URL. This could open up the door to phishing situations or unexpected behaviour.Rather than attempting to make the regex safe to use, I opted to re-write the code without the need for regex. This uses built in Javascript URL for more accurate comparisons.
Related issues
https://github.com/MetaMask/mobile-planning/issues/1571
Manual testing steps
Pre-merge author checklist
Pre-merge reviewer checklist