Skip to content
This repository
Browse code

Make TextHelper::auto_link recognize URLs with colons in path correct…

…ly, fixes #7268

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 8e82e2901004c3604da74d23220e7fc241aba739 1 parent 0f8ed48
Thomas Fuchs authored January 21, 2007
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268.  [imajes]
  4
+
3 5
 * Update to script.aculo.us 1.7.0.  [Thomas Fuchs]
4 6
 
5 7
 * Modernize cookie testing code, and increase coverage (Heckle++) #7101 [Kevin Clark]
28  actionpack/lib/action_view/helpers/text_helper.rb
@@ -354,26 +354,26 @@ def set_cycle(name, cycle_object)
354 354
           @_cycles = Hash.new unless defined?(@_cycles)
355 355
           @_cycles[name] = cycle_object
356 356
         end
357  
-      
  357
+
358 358
         AUTO_LINK_RE = %r{
359  
-                        (                         # leading text
360  
-                          <\w+.*?>|               # leading HTML tag, or
361  
-                          [^=!:'"/]|              # leading punctuation, or 
362  
-                          ^                       # beginning of line
  359
+                        (                          # leading text
  360
+                          <\w+.*?>|                # leading HTML tag, or
  361
+                          [^=!:'"/]|               # leading punctuation, or 
  362
+                          ^                        # beginning of line
363 363
                         )
364 364
                         (
365  
-                          (?:https?://)|          # protocol spec, or
366  
-                          (?:www\.)               # www.*
  365
+                          (?:https?://)|           # protocol spec, or
  366
+                          (?:www\.)                # www.*
367 367
                         ) 
368 368
                         (
369  
-                          [-\w]+                  # subdomain or domain
370  
-                          (?:\.[-\w]+)*           # remaining subdomains or domain
371  
-                          (?::\d+)?               # port
372  
-                          (?:/(?:[~\w\+%.;-]+)?)* # path
373  
-                          (?:\?[\w\+%&=.;-]+)?    # query string
374  
-                          (?:\#[\w\-]*)?          # trailing anchor
  369
+                          [-\w]+                   # subdomain or domain
  370
+                          (?:\.[-\w]+)*            # remaining subdomains or domain
  371
+                          (?::\d+)?                # port
  372
+                          (?:/(?:[~\w\+%.;:-]+)?)* # path
  373
+                          (?:\?[\w\+%&=.;-]+)?     # query string
  374
+                          (?:\#[\w\-]*)?           # trailing anchor
375 375
                         )
376  
-                        ([[:punct:]]|\s|<|$)      # trailing text
  376
+                        ([[:punct:]]|\s|<|$)       # trailing text
377 377
                        }x unless const_defined?(:AUTO_LINK_RE)
378 378
 
379 379
         # Turns all urls into clickable links.  If a block is given, each url
4  actionpack/test/template/text_helper_test.rb
@@ -131,7 +131,9 @@ def test_auto_link_parsing
131 131
               http://www.rubyonrails.com/contact;new
132 132
               http://www.rubyonrails.com/contact;new%20with%20spaces
133 133
               http://www.rubyonrails.com/contact;new?with=query&string=params
134  
-              http://www.rubyonrails.com/~minam/contact;new?with=query&string=params)
  134
+              http://www.rubyonrails.com/~minam/contact;new?with=query&string=params
  135
+              http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
  136
+            )
135 137
 
136 138
     urls.each do |url|
137 139
       assert_equal %(<a href="#{url}">#{url}</a>), auto_link(url)

0 notes on commit 8e82e29

Please sign in to comment.
Something went wrong with that request. Please try again.