-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 |
||
link.setAttribute('href', `http://${url}`); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Does this test really make sense in this context? |
||
return new URL(apiUrl); | ||
} | ||
const { subdomain } = APPS_CONFIGURATION[appName]; | ||
const url = new URL(apiUrl); | ||
const { hostname } = url; | ||
|
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 checkhxxps
andhxxp
.