From 835cb43745e79521514738044b3cf0232957de0b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 20 Sep 2007 08:27:45 +0000 Subject: Revert [7397]. Reopens #7313. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7515 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/text_helper.rb | 16 +++++----------- actionpack/test/template/text_helper_test.rb | 4 ---- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 36795bf498..0c1d92cdc6 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -305,7 +305,7 @@ module ActionView def auto_link(text, link = :all, href_options = {}, &block) return '' if text.blank? case link - when :all then auto_link_email_addresses(auto_link_urls(text, href_options, &block), &block) + when :all then auto_link_urls(auto_link_email_addresses(text, &block), href_options, &block) when :email_addresses then auto_link_email_addresses(text, &block) when :urls then auto_link_urls(text, href_options, &block) end @@ -534,8 +534,8 @@ module ActionView [-\w]+ # subdomain or domain (?:\.[-\w]+)* # remaining subdomains or domain (?::\d+)? # port - (?:/(?:(?:[~\w\+@%-]|(?:[,.;:][^\s$]))+)?)* # path - (?:\?[\w\+@%&=.;-]+)? # query string + (?:/(?:(?:[~\w\+%-]|(?:[,.;:][^\s$]))+)?)* # path + (?:\?[\w\+%&=.;-]+)? # query string (?:\#[\w\-]*)? # trailing anchor ) ([[:punct:]]|\s|<|$) # trailing text @@ -560,16 +560,10 @@ module ActionView # Turns all email addresses into clickable links. If a block is given, # each email is yielded and the result is used as the link text. def auto_link_email_addresses(text) - body = text.dup text.gsub(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do text = $1 - - if body.match(/]*>(.*)(#{text})(.*)<\/a>/) - text - else - display_text = (block_given?) ? yield(text) : text - %{#{display_text}} - end + text = yield(text) if block_given? + %{#{text}} end end end diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index e0bbc32a7b..1f5b90e811 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -157,7 +157,6 @@ class TextHelperTest < Test::Unit::TestCase http://www.rubyonrails.com/contact;new?with=query&string=params http://www.rubyonrails.com/~minam/contact;new?with=query&string=params http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007 - http://www.mail-archive.com/rails@lists.rubyonrails.org/ ) urls.each do |url| @@ -187,8 +186,6 @@ class TextHelperTest < Test::Unit::TestCase link8_result = %{#{link8_raw}} link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html' link9_result = %{#{link9_raw}} - link10_raw = 'http://www.mail-archive.com/ruby-talk@ruby-lang.org/' - link10_result = %{#{link10_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) @@ -228,7 +225,6 @@ class TextHelperTest < Test::Unit::TestCase 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 %(

#{link10_result} Link

), auto_link("

#{link10_raw} Link

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