diff --git a/app/helpers/display_helper.rb b/app/helpers/display_helper.rb
index 94d6c6e..5443678 100644
--- a/app/helpers/display_helper.rb
+++ b/app/helpers/display_helper.rb
@@ -31,9 +31,10 @@ module DisplayHelper
gsub( /\n\s*\n/, '
' ).
gsub( /\n/, '
' ).
gsub( /(^|\s)(www\.[^\s])/, '\1http://\2' ).
- gsub( /(https?:\/\/([^\s]+))/,
- '\2' )
+ gsub( /(https?:\/\/([^\s]+))/ ) do
+ href, content = $1, $2.scan(/.{4}/).join('')
+ content_tag(:a, content, :href => href, :target => '_blank', :rel => 'nofolow',
+ :onclick => "return confirm('%s')" % escape_javascript(_('Are you sure you want to visit this web site?')))
+ end
end
end
diff --git a/test/functional/catalog_controller_test.rb b/test/functional/catalog_controller_test.rb
index d8730f1..b4000ef 100644
--- a/test/functional/catalog_controller_test.rb
+++ b/test/functional/catalog_controller_test.rb
@@ -80,4 +80,11 @@ class CatalogControllerTest < Test::Unit::TestCase
assert_tag :tag => 'a', :attributes => {:href => /assets\/products\?product_category=#{pc.id}/}
end
+ should 'add an zero width space every 4 caracters of comment urls' do
+ url = 'www.an.url.to.be.splited.com'
+ prod = @enterprise.products.create!(:name => 'Product test', :price => 50.00, :product_category => @product_category, :description => url)
+ get :index, :profile => @enterprise.identifier
+ assert_tag :a, :attributes => { :href => "http://" + url}, :content => url.scan(/.{4}/).join('')
+ end
+
end
diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb
index 7c57e2a..a9bc23a 100644
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -1245,4 +1245,12 @@ class ContentViewerControllerTest < Test::Unit::TestCase
assert_redirected_to :profile => @profile.identifier, :page => page.explode_path
end
+ should 'add an zero width space every 4 caracters of comment urls' do
+ url = 'www.an.url.to.be.splited.com'
+ a = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en')
+ c = a.comments.create!(:author => @profile, :title => 'An url', :body => url)
+ get :view_page, :profile => @profile.identifier, :page => [ 'textile' ]
+ assert_tag :a, :attributes => { :href => "http://" + url}, :content => url.scan(/.{4}/).join('')
+ end
+
end
--
libgit2 0.21.2