spamscanner / url-regex-safe

Regular expression matching for URL's. Maintained, safe, and browser-friendly version of url-regex. Resolves CVE-2020-7661 for Node.js servers.
https://forwardemail.net/docs/url-regex-javascript-node-js
MIT License
79 stars 14 forks source link

Regex not matching URLS #10

Closed NN-Binary closed 1 year ago

NN-Binary commented 3 years ago

Hi,

<img class="central-featured-logo" src="portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png" srcset="portal/wikipedia.org/assets/img/Wikipedia-logo-v2@1.5x.png 1.5x, portal/wikipedia.org/assets/img/Wikipedia-logo-v2@2x.png 2x" width="200" height="183" alt="Wikipedia">

(Wikipedia Homepage) Here the URL that is matched is wikipedia.org/assets/img/Wikipedia-logo-v2.png instead of portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png

        var matches = StringToMatch.match(urlRegexSafe({
            localhost: false,
            ipv4: false,
            ipv6: false
        }));

Am I doing something wrong or it's url-regex-safe that isn't doing proper match? Thanks for the help

nicod-pc commented 3 years ago

portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png is a path, not an URL. wikipedia.org/assets/img/Wikipedia-logo-v2.png isn't an url, too, but wikipedia.org looks like a domain, so this lib tries to make an URL out of it, I guess.