From ef1d0c1259337638983804ea0f97f25f2b3f02e4 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 24 Jan 2007 18:42:03 +0000 Subject: Autolinking recognizes trailing and embedded . , : ; Closes #7354. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6034 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/text_helper.rb | 2 +- actionpack/test/template/text_helper_test.rb | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'actionpack') 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 = %{#{link6_raw}} link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123' link7_result = %{#{link7_raw}} + link8_raw = 'http://foo.example.com:3000/controller/action.html' + link8_result = %{#{link8_raw}} + link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html' + link9_result = %{#{link9_raw}} 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 %(

#{link5_result} Link

), auto_link("

#{link5_raw} Link

") assert_equal %(

#{link6_result} Link

), auto_link("

#{link6_raw} Link

") assert_equal %(

#{link7_result} Link

), auto_link("

#{link7_raw} Link

") + 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 %(

Link #{link8_result}

), auto_link("

Link #{link8_raw}

") + assert_equal %(

#{link8_result} Link

), auto_link("

#{link8_raw} Link

") + assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.)) + assert_equal %(

Go to #{link8_result}. seriously, #{link8_result}? i think I'll say hello to #{email_result}. instead.

), auto_link(%(

Go to #{link8_raw}. seriously, #{link8_raw}? i think I'll say hello to #{email_raw}. instead.

)) + 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 %(

Link #{link9_result}

), auto_link("

Link #{link9_raw}

") + assert_equal %(

#{link9_result} Link

), auto_link("

#{link9_raw} Link

") + assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.)) + assert_equal %(

Go to #{link9_result}. seriously, #{link9_result}? i think I'll say hello to #{email_result}. instead.

), auto_link(%(

Go to #{link9_raw}. seriously, #{link9_raw}? i think I'll say hello to #{email_raw}. instead.

)) assert_equal '', auto_link(nil) assert_equal '', auto_link('') end -- cgit v1.2.3