mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-09 10:15:26 +00:00
Merge 6cc3329b26 into d3661170a4
This commit is contained in:
@@ -20,31 +20,6 @@ const ALLOWED_ORIGINS = [
|
|||||||
"rolt.chat",
|
"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
|
* Determine what kind of link we are dealing with and sanitise any malicious input
|
||||||
* @param href Input URL
|
* @param href Input URL
|
||||||
@@ -65,11 +40,9 @@ export function determineLink(href?: string): LinkType {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
if (!internal && url) {
|
if (!internal && url) {
|
||||||
if (PROTOCOL_WHITELIST.includes(url.protocol)) {
|
|
||||||
return { type: "external", href, url };
|
return { type: "external", href, url };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return { type: "none" };
|
return { type: "none" };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user