Bug 21485 - URL regular expression fails on long strings
Summary: URL regular expression fails on long strings
Status: RESOLVED DUPLICATE of bug 18327
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-10-08 14:32 PDT by Patrick Johnson
Modified: 2009-03-19 15:06 PDT (History)
2 users (show)

See Also:


Attachments
Test case (1.06 KB, text/html)
2008-10-08 14:42 PDT, Patrick Johnson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Johnson 2008-10-08 14:32:42 PDT
The following regular expression fails if given a string longer than 450 characters:

  /^((\w+):\/\/)(([^:]+):?([^@]+)?@)?([^\/\?:]*):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(.+)?/

This regex is used by the Selenium project to determine whether a string is a valid URL.

I have observed this in Safari 3.1.2 (on Windows) and Google Chrome/Chromium.

This is very possibly the same as:
https://bugs.webkit.org/show_bug.cgi?id=18327
Comment 1 Mark Rowe (bdash) 2008-10-08 14:35:21 PDT
<rdar://problem/6279213>
Comment 2 Patrick Johnson 2008-10-08 14:42:49 PDT
Created attachment 24201 [details]
Test case
Comment 3 Barry Ferg 2009-03-03 09:04:14 PST
*** Bug 24308 has been marked as a duplicate of this bug. ***
Comment 4 Levin Alexander 2009-03-16 11:20:38 PDT
saw something that seems to be the same bug:  the ExtJs framework has a regular expression to validate email addresses:

  var mailrx = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;

using this regular expression causes the following test cases to fail in Webkit Nightlies and the Safari 4 beta

  testRegularExpressionMatching: function() {
    this.assert("info@exactlytwentycharac.com".match(mailrx));    /* fails */    
    this.assert("info@lessthantwentychar.com".match(mailrx));     /* passes */
    this.assert("info@foo.lessthantwentychars.de".match(mailrx)); /* fails */
  },

(This is on OS X 10.5 with all updates, the Safari 4 beta installed and using WebKit r41707)
Comment 5 Geoffrey Garen 2009-03-19 15:06:38 PDT

*** This bug has been marked as a duplicate of 18327 ***