Ticket #8864: fix_strip_links.patch
| File fix_strip_links.patch, 1.4 kB (added by lifofifo, 1 year ago) |
|---|
-
actionpack/test/template/text_helper_test.rb
old new 48 48 49 49 def test_strip_links 50 50 assert_equal "on my mind\nall day long", strip_links("<a href='almost'>on my mind</a>\n<A href='almost'>all day long</A>") 51 assert_equal "0wn3d", strip_links("<a href='http://www.rubyonrails.com/'><a href='http://www.rubyonrails.com/' onlclick='steal()'>0wn3d</a></a>") 52 assert_equal "Magic", strip_links("<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic") 51 53 end 52 54 53 55 def test_highlighter 54 56 assert_equal( 55 57 "This is a <strong class=\"highlight\">beautiful</strong> morning", -
actionpack/lib/action_view/helpers/text_helper.rb
old new 323 323 # strip_links('Blog: <a href="http://www.myblog.com/" class="nav" target=\"_blank\">Visit</a>.') 324 324 # # => Blog: Visit 325 325 def strip_links(text) 326 text.gsub(/<a\b.*?> (.*?)<\/a>/mi, '\1')326 text.gsub(/<a\b.*?>/mi, '').gsub(/<\/a>/i, '') 327 327 end 328 328 329 329 VERBOTEN_TAGS = %w(form script plaintext) unless defined?(VERBOTEN_TAGS)