You found a bug! We've classified it as EXTJSIV-7566 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    keithrz is on a distinguished road

      0  

    Default URL vtype should not allow spaces

    URL vtype should not allow spaces


    Using ExtJS 4.1.1

    The url vtype thinks the following URL is valid:
    http://www.grammar school.com

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    keithrz is on a distinguished road

      0  

    Default


    The interesting thing here is that the regex for urls does not allow spaces. But Javascript's test() method for regex returns true if is testing a string that contains substrings that match the regex (and those substrings are only separated by whitespace.)


    http://www.grammar school.com


    returns true because the following strings match the regex:
    ['http://www.grammar', 'school.com']


    Here is my workaround: use the same regex, but use exec() instead of test(). The url regex is the same - it is copied because I did not have scope access to the original regex in the VType closure.


    Code:
    Ext.override(Ext.form.field.VTypes, {
        urlRegex: /(((^https?)|(^ftp)):\/\/((([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*)|(localhost|LOCALHOST))\/?)/i,
        'url': function(urlToTest) {
            var urlMatches = this.urlRegex.exec(urlToTest);
            if(urlMatches && urlMatches.length > 0) {
                return (urlMatches[0] === urlToTest);
            } else {
                 return false;
            }
        }
    });

Tags for this Thread