mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
Fix Link Whitelist issue
This commit is contained in:
@@ -20,31 +20,6 @@ const ALLOWED_ORIGINS = [
|
||||
"rolt.chat",
|
||||
];
|
||||
|
||||
/**
|
||||
* Permissible protocols in URLs
|
||||
*/
|
||||
const PROTOCOL_WHITELIST = [
|
||||
"http:",
|
||||
"https:",
|
||||
"ftp:",
|
||||
"ftps:",
|
||||
"mailto:",
|
||||
"news:",
|
||||
"irc:",
|
||||
"gopher:",
|
||||
"nntp:",
|
||||
"feed:",
|
||||
"telnet:",
|
||||
"mms:",
|
||||
"rtsp:",
|
||||
"svn:",
|
||||
"git:",
|
||||
"tel:",
|
||||
"fax:",
|
||||
"xmpp:",
|
||||
"magnet:",
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine what kind of link we are dealing with and sanitise any malicious input
|
||||
* @param href Input URL
|
||||
@@ -65,11 +40,9 @@ export function determineLink(href?: string): LinkType {
|
||||
} catch (err) {}
|
||||
|
||||
if (!internal && url) {
|
||||
if (PROTOCOL_WHITELIST.includes(url.protocol)) {
|
||||
return { type: "external", href, url };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { type: "none" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user