Maheshjayachandran / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.string.linkifier incorrectly links URLs including ) and > #491

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
  1. Throw some text at
     `goog.string.linkifier.findFirstUrl/linkifyPlainText`
     with with URLs formed like "<http://google.com/>" or
     "(www.yahoo.com)" (note the ')' and '>' characters).

What is the expected output? What do you see instead?

  Expected output is for 'http://google.com/' to be linked, as well as
  'www.yahoo.com'. Instead, 'http://google.com/>' and 'www.yahoo.com)'
  will be linked, respectively.

What version of the product are you using? On what operating system?

  Closure Library r2118, Firefox 14.0.1, Mac OSX 10.7.2.

Please provide any additional information below.

  This is a result of an erroneous character class in
  goog.string.linkify.ACCEPTABLE_URL_CHARS_, '#-@' when it seems the
  author intended '#\\-@', escaping the hyphen. I came to this
  conclusion because other characters are included in the character
  class which are included in the #-@ range. A quick test to see them
  all:

    for (var i = String.charCodeAt('#'), l = String.charCodeAt('@');
         i < l; i++)
      console.log(
        String.fromCharCode(i),
        /\w/.test(String.fromCharCode(i))
      );

  I've attached a patch for this with the fix and a test case (I've
  already submitted the CLA).

Original issue reported on code.google.com by thomasma...@gmail.com on 23 Aug 2012 at 6:47

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by pall...@google.com on 29 Jul 2013 at 8:39