diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-24 18:42:03 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-24 18:42:03 +0000 |
commit | ef1d0c1259337638983804ea0f97f25f2b3f02e4 (patch) | |
tree | a5481be7c26b33c44b390596d835afac77403491 /actionpack | |
parent | 1d8cd1d744fd1e8b25aa764ddd59ef1aa100eff4 (diff) | |
download | rails-ef1d0c1259337638983804ea0f97f25f2b3f02e4.tar.gz rails-ef1d0c1259337638983804ea0f97f25f2b3f02e4.tar.bz2 rails-ef1d0c1259337638983804ea0f97f25f2b3f02e4.zip |
Autolinking recognizes trailing and embedded . , : ; Closes #7354.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6034 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 16 |
3 files changed, 19 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index df232d4931..682fb728b2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Autolinking recognizes trailing and embedded . , : ; #7354 [Jarkko Laine] + * Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes] * Update to script.aculo.us 1.7.0. [Thomas Fuchs] diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 324ab54130..236e1492ac 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -369,7 +369,7 @@ module ActionView [-\w]+ # subdomain or domain (?:\.[-\w]+)* # remaining subdomains or domain (?::\d+)? # port - (?:/(?:[~\w\+%.;:-]+)?)* # path + (?:/(?:(?:[~\w\+%-]|(?:[,.;:][^\s$]))+)?)* # path (?:\?[\w\+%&=.;-]+)? # query string (?:\#[\w\-]*)? # trailing anchor ) diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index a8b566cb85..18f2375969 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -158,6 +158,10 @@ class TextHelperTest < Test::Unit::TestCase link6_result = %{<a href="#{link6_raw}">#{link6_raw}</a>} link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123' link7_result = %{<a href="#{link7_raw}">#{link7_raw}</a>} + link8_raw = 'http://foo.example.com:3000/controller/action.html' + link8_result = %{<a href="#{link8_raw}">#{link8_raw}</a>} + link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html' + link9_result = %{<a href="#{link9_raw}">#{link9_raw}</a>} assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses) assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls) @@ -185,6 +189,18 @@ class TextHelperTest < Test::Unit::TestCase assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>") assert_equal %(<p>#{link6_result} Link</p>), auto_link("<p>#{link6_raw} Link</p>") assert_equal %(<p>#{link7_result} Link</p>), auto_link("<p>#{link7_raw} Link</p>") + assert_equal %(Go to #{link8_result}), auto_link("Go to #{link8_raw}", :urls) + assert_equal %(Go to #{link8_raw}), auto_link("Go to #{link8_raw}", :email_addresses) + assert_equal %(<p>Link #{link8_result}</p>), auto_link("<p>Link #{link8_raw}</p>") + assert_equal %(<p>#{link8_result} Link</p>), auto_link("<p>#{link8_raw} Link</p>") + assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.)) + assert_equal %(<p>Go to #{link8_result}. seriously, #{link8_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link8_raw}. seriously, #{link8_raw}? i think I'll say hello to #{email_raw}. instead.</p>)) + assert_equal %(Go to #{link9_result}), auto_link("Go to #{link9_raw}", :urls) + assert_equal %(Go to #{link9_raw}), auto_link("Go to #{link9_raw}", :email_addresses) + assert_equal %(<p>Link #{link9_result}</p>), auto_link("<p>Link #{link9_raw}</p>") + assert_equal %(<p>#{link9_result} Link</p>), auto_link("<p>#{link9_raw} Link</p>") + assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.)) + assert_equal %(<p>Go to #{link9_result}. seriously, #{link9_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link9_raw}. seriously, #{link9_raw}? i think I'll say hello to #{email_raw}. instead.</p>)) assert_equal '', auto_link(nil) assert_equal '', auto_link('') end |