Foundation-sites: [Abide] URL validation fails when URL encoded commas are in the URL.

Created on 15 Sep 2016  ·  5Comments  ·  Source: foundation/foundation-sites

How can we reproduce this bug?

  1. Create a URL validated text input
  2. Use a URL that has a comma that is url Encoded. An example would be "https://www.google.com/#q=Et%2Ctu%2Cbrute"
  3. Shift focus off of the input.

What did you expect to happen?
%2C is a valid URL encoded character. I expect abide not to balk at the URL.

What happened instead?
Abide flags the input as invalid.

Test case:
http://codepen.io/jellisii/pen/amNZJN

This is also a problem with Foundation5 as well.

Abide PR open

Most helpful comment

@brettsmason this one seems more reasonable to test for than localhost in the other issue. I'll check it out.

All 5 comments

@dperini has a gist that appears to resolve this issue: https://gist.github.com/dperini/729294. If this resolves the issue properly is a bit of a mystery to me, because I haven't sat down to sort out the regex in the abide library.

I was able to use it for my purposes (in Foundation 5) by overriding the existing URL validator:

Foundation.libs.abide.settings.patterns.url = new RegExp(
  "^" +
    // protocol identifier
    "(?:(?:https?|ftp)://)" +
    // user:pass authentication
    "(?:\\S+(?::\\S*)?@)?" +
    "(?:" +
      // IP address exclusion
      // private & local networks
      "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
      "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
      "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
      // IP address dotted notation octets
      // excludes loopback network 0.0.0.0
      // excludes reserved space >= 224.0.0.0
      // excludes network & broacast addresses
      // (first & last IP address of each class)
      "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
      "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
      "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
    "|" +
      // host name
      "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
      // domain name
      "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
      // TLD identifier
      "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
      // TLD may end with dot
      "\\.?" +
    ")" +
    // port number
    "(?::\\d{2,5})?" +
    // resource path
    "(?:[/?#]\\S*)?" +
  "$", "i"
);

@colin-marshall I see you closed #9815 which was linked to this.
Any feeling on if you think this should be addressed or not? Never used Abide so I'm in the dark on this one!

@brettsmason this one seems more reasonable to test for than localhost in the other issue. I'll check it out.

Bump =)

Thanks for the bump @DanielRuf.
See https://github.com/zurb/foundation-sites/pull/11116

Was this page helpful?
0 / 5 - 0 ratings