-
Notifications
You must be signed in to change notification settings - Fork 578
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
Add checks to prevent formatting hxxps #405
base: main
Are you sure you want to change the base?
Conversation
1) sanitizeUrl.ts: if the url starts with hxxps it will return the url 2) transformLinks.ts: checks to make sure the url does not start with hxxps 3) url.ts: if the input starts with hxxps it will return it I tried my best to dig through these files to solve this (https://protonmail.uservoice.com/forums/284483-proton-mail/suggestions/48747251-stop-hyperlinking-hxxps) instead of just complaining about it.
@@ -51,7 +51,7 @@ const sanitizeRelativeHttpLinks = (link: HTMLLinkElement) => { | |||
// link.href is the absolute value of the link: mail.proton.me is prepended, use getAttribute | |||
const url = link.getAttribute('href'); | |||
|
|||
if (url) { | |||
if (url && !url.toLowerCase().startsWith('hxxps')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the customization in this function make any sense at all? A URL is always passed without a protocol and if this starts with hxxps, then in my opinion the http:// should still be added.
Example hxxps.example.com
should become http://hxxps.example.com
. With your adjustment it will not longer work.
@@ -3,6 +3,10 @@ export const sanitizeUrl = (url: string): string | undefined => { | |||
return undefined | |||
} | |||
|
|||
if (url.toLowerCase().startsWith('hxxps')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check should probably be moved to line 16 and you should use the parsedUrl.protocol
for the check. Also check hxxps
and hxxp
.
@@ -229,6 +229,9 @@ export const getApiSubdomainUrl = (pathname: string, origin: string) => { | |||
}; | |||
|
|||
export const getAppUrlFromApiUrl = (apiUrl: string, appName: APP_NAMES) => { | |||
if (apiUrl.toLowerCase().startsWith('hxxps')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test really make sense in this context?
I tried my best to dig through these files to solve this (https://protonmail.uservoice.com/forums/284483-proton-mail/suggestions/48747251-stop-hyperlinking-hxxps) instead of just complaining about it. Feel free to refactor, reformat, or edit. Thanks for the consideration.