Skip to content

Commit

Permalink
Merge pull request #2514 from reosarevok/MBS-12352
Browse files Browse the repository at this point in the history
MBS-12350 / MBS-12352 / MBS-12383 / MBS-12396 / MBS-12401: Block more "smart" links
  • Loading branch information
reosarevok committed Jun 13, 2022
2 parents 4e69325 + b126ea4 commit 8b4d5b7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions root/static/scripts/edit/externalLinks.js
Expand Up @@ -1586,14 +1586,23 @@ function isValidURL(url: string) {
return true;
}

// For shortener pages which should still be allowed as a host-only link
const SHORTENER_ALLOWED_HOSTS = [
'bruit.app',
'distrokid.com',
'trac.co',
];

const URL_SHORTENERS = [
'adf.ly',
'album.link',
'ampl.ink',
'amu.se',
'artist.link',
'band.link',
'bfan.link',
'biglink.to',
'bio.link',
'bit.ly',
'bitly.com',
'backl.ink',
Expand All @@ -1613,7 +1622,9 @@ const URL_SHORTENERS = [
'gate.fm',
'geni.us',
'goo.gl',
'hypeddit.com',
'hypel.ink',
'hyperfollow.com',
'hyperurl.co',
'is.gd',
'kl.am',
Expand Down Expand Up @@ -1654,19 +1665,25 @@ const URL_SHORTENERS = [
'spoti.fi',
'sptfy.com',
'spread.link',
'streamerlinks.com',
'streamlink.to',
'su.pr',
't.co',
'tiny.cc',
'tinyurl.com',
'tourlink.to',
'trac.co', // Host links can be legitimate; non-root paths are aggregators
'trac.co',
'u.nu',
'unitedmasters.com',
'untd.io',
'vyd.co',
'yep.it',
].map(host => new RegExp('^https?://([^/]+\\.)?' + host + '/.+', 'i'));
].map(shortener => new RegExp(
'^https?://([^/]+\\.)?' +
shortener +
(SHORTENER_ALLOWED_HOSTS.includes(shortener) ? '/.+' : ''),
'i',
));

function isShortened(url) {
return URL_SHORTENERS.some(function (shortenerRegex) {
Expand Down

0 comments on commit 8b4d5b7

Please sign in to comment.