New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use updated dperini's url regex #153

Closed
huan086 opened this Issue Aug 29, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@huan086

huan086 commented Aug 29, 2016

dperini updated the gist

old code

          "(?!10(?:\\.\\d{1,3}){3})" +
          "(?!127(?:\\.\\d{1,3}){3})" +
          "(?!169\\.254(?:\\.\\d{1,3}){2})" +
          "(?!192\\.168(?:\\.\\d{1,3}){2})" +

...

          // path
          "(?:\\/[^\\s]*)?" +

new code

      "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
"(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
...
    // resource path
"(?:[/?#]\\S*)?" +

major change is that http://example.com?query and http://example.com#query used to be detected as invalid (that's bad), while the new regex allows them

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Aug 29, 2016

Owner

Can you show a case where the existing validate.js code doesn't work?

Both queries and fragments work: https://github.com/ansman/validate.js/blob/master/specs/validators/url-spec.js#L73

Owner

ansman commented Aug 29, 2016

Can you show a case where the existing validate.js code doesn't work?

Both queries and fragments work: https://github.com/ansman/validate.js/blob/master/specs/validators/url-spec.js#L73

@huan086

This comment has been minimized.

Show comment
Hide comment
@huan086

huan086 Aug 30, 2016

http://example.com/path?query works, but http://example.com?query doesn't. dperini's updated gist fixes that

huan086 commented Aug 30, 2016

http://example.com/path?query works, but http://example.com?query doesn't. dperini's updated gist fixes that

@ansman ansman closed this in cffa61a Aug 31, 2016

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Aug 31, 2016

Owner

Got it, thanks.

Owner

ansman commented Aug 31, 2016

Got it, thanks.

@ansman ansman added the bug label Aug 31, 2016

@ansman ansman added this to the Next milestone Aug 31, 2016

@huan086

This comment has been minimized.

Show comment
Hide comment
@huan086

huan086 Sep 1, 2016

Oh wait, I realized that's not all.

Hostname match is now

(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)

instead of

(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)

which solves the catastrophic backtracking problem by removing the +, and also supports http://g--a.com

It would be wise to update the entire regex in order to get all the fixes

huan086 commented Sep 1, 2016

Oh wait, I realized that's not all.

Hostname match is now

(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)

instead of

(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)

which solves the catastrophic backtracking problem by removing the +, and also supports http://g--a.com

It would be wise to update the entire regex in order to get all the fixes

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Sep 6, 2016

Owner

Done

Owner

ansman commented Sep 6, 2016

Done

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Nov 5, 2016

Owner

Released in 0.11.0

Owner

ansman commented Nov 5, 2016

Released in 0.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment