News for hackers. Stuff that matters.
Re:In search of the perfect URL validation regex (2010) by likium on Saturday September 25, 2021 @03:23PM (#28655557)
Even if you built a URL validation regex that follows rfc3986[1] and rfc3987[2], you will still get user bug reports because web browsers follow a different standard.

For example, <http://example.com./> , <http:///example.com/> and <https://en.wikipedia.org/wiki/Space (punctuation)> are classified as invalid urls in the blog, but they are accepted in the browser.

As the creator of cURL puts it, there is no URL standard[3].

[1]: https://www.ietf.org/rfc/rfc3986.txt

[2]: https://www.ietf.org/rfc/rfc3987.txt

[3]: https://daniel.haxx.se/blog/2016/05/11/my-url-isnt-your-url/

Re:In search of the perfect URL validation regex (2010) by yyyk on Saturday September 25, 2021 @04:29PM (#28655965)
Re:In search of the perfect URL validation regex (2010) by MildlySerious on Saturday September 25, 2021 @05:19PM (#28656272)
Tangentially, Youtube had a bug surface last year where adding that extra dot let you avoid all ads. Previous discussion[1]

[1] https://news.ycombinator.com/item?id=23479435

Re:In search of the perfect URL validation regex (2010) by userbinator on Saturday September 25, 2021 @09:49PM (#28657701)
This "bug", can definitely also be known as a feature ;-)
Re:In search of the perfect URL validation regex (2010) by dhsysusbsjsi on Saturday September 25, 2021 @05:41PM (#28656449)
Also nearly every paywalled media site
Re:In search of the perfect URL validation regex (2010) by Sephr on Saturday September 25, 2021 @03:31PM (#28655612)
There might not have been a generally accepted standard then, but there is now: https://url.spec.whatwg.org/
Re:In search of the perfect URL validation regex (2010) by jt2190 on Saturday September 25, 2021 @05:08PM (#28656200)
There's also a question of what we're really trying to validate, IMHO. All of these regex patterns will tell you that a string looks like a URL, but they won't actually tell you if: There's any web server listening at that particular URL; Whether that server has the resource in that location; If that server is reachable from where you want to fetch it; etc.
Re:In search of the perfect URL validation regex (2010) by staticassertion on Saturday September 25, 2021 @08:33PM (#28657359)
> All of these regex patterns will tell you that a string looks like a URL,

yeah that's it that's what they're trying to validate

Re:In search of the perfect URL validation regex (2010) by MPSimmons on Sunday September 26, 2021 @01:43PM (#28662860)
It seems like the answer is almost always yes.