Skip to content

Commit

Permalink
Fix Link Whitelist issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dolphin-cat authored Mar 16, 2024
1 parent 5b6546b commit 6cc3329
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions src/lib/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,9 +40,7 @@ export function determineLink(href?: string): LinkType {
} catch (err) {}

if (!internal && url) {
if (PROTOCOL_WHITELIST.includes(url.protocol)) {
return { type: "external", href, url };
}
return { type: "external", href, url };
}
}

Expand Down

0 comments on commit 6cc3329

Please sign in to comment.