Skip to content

Commit

Permalink
fix(isMagnetURI): prevent matching hashes longer than 40 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
tux-tn committed Sep 20, 2021
1 parent e263b32 commit 3c4157a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isMagnetURI.js
@@ -1,6 +1,6 @@
import assertString from './util/assertString';

const magnetURI = /^magnet:\?xt(\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?(?:&.+)?/i;
const magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?(?:&.+)?$/i;

export default function isMagnetURI(url) {
assertString(url);
Expand Down
1 change: 1 addition & 0 deletions test/validators.js
Expand Up @@ -9315,6 +9315,7 @@ describe('Validators', () => {
'magnet:?xt:btih:ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'magnet:?xt:urn:nonexisting:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234',
'magnet:?xt.2=urn:btih:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234',
'magnet:?xt=urn:ed2k:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890123456789ABCD',
],
});
/* eslint-enable max-len */
Expand Down

0 comments on commit 3c4157a

Please sign in to comment.