-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(input[url]): Invalid URLS incorrectly valid #7816
Conversation
The current URL regex incorrectly matches invalid urls. Examples: http://www.. http:/// http://[[ The new regex should correctly identify urls
Switched regex to new RegExp format so that I could pass the JShint test for lines that are too long
Fix spacing so quotes line up (with the exception of 1 line where \ needs to be escaped
Fix typo when changing spacing
my fix is currently failing the test for: Pretty much it's handling all cases except for domains without an extension. Any regex experts want to help? |
Url validation is currently following Chromium and FF, which is following rfc1035 |
I'm not sure we want a regexp like that in the tree, because that is kind of frightening. As I've said in another issue, URL validation in browsers is a bit more complicated and relies on quite a bit more than a simple regexp, so it's hard for us to be as robust as them. I think there are some things we could add which would be worth doing, like supporting any scheme, or scheme-less urls (such as CDN urls), but there's a limit to how robust we can be when we're relying on a regular expression. Even so, maybe someone else has a different opinion, @shahata WDYT about this? |
at the very least I don't think the regex should allow things like http://www.. and http:/// The way I came across the bug was doing url validation for a form. Those are 2 probable mistakes that could be entered that I feel should be caught by the regex. |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
There's been a change last year that made the url regex much less strict: e3be5d6 I haven't tested your examples, but I assume they are covered by this. |
The current URL regex incorrectly matches invalid urls.
Examples:
http://www..
http:///
http://[[
The new regex should correctly identify urls