[Git][noosfero/noosfero][master] 2 commits: not escape HTML of link to read more article on blog index with short format

Bráulio Bhavamitra gitlab at mg.gitlab.com
Tue Jun 7 17:17:44 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
6f15dc60 by Melissa Wen at 2016-06-07T15:34:55-04:00
not escape HTML of link to read more article on blog index with short format

- - - - -
4ed8d8c3 by Bráulio Bhavamitra at 2016-06-07T20:17:23+00:00
Merge branch 'fix_escape_html_on_display_short_format_of_article' into 'master'

not escape HTML of link to read more article on blog index with short format

This commit wants to fix escape HTML on read more link on blog posts list when post not accept comments and blog is setup to display short format as image attached
![Destaques_-_Use_the_environment_-_2016-06-07_10.07.06](/uploads/762b5b8921c8cd1a657e8d1d8c87985b/Destaques_-_Use_the_environment_-_2016-06-07_10.07.06.png)

See merge request !958
- - - - -


2 changed files:

- app/helpers/application_helper.rb
- test/integration/safe_strings_test.rb


Changes:

=====================================
app/helpers/application_helper.rb
=====================================
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -723,11 +723,11 @@ module ApplicationHelper
   def display_short_format(article, options={})
     options[:comments_link] ||= true
     options[:read_more_link] ||= true
+    lead_links = (options[:comments_link] ? link_to_comments(article) : '') + (options[:read_more_link] ? reference_to_article( _('Read more'), article) : '')
     html = content_tag('div',
              article.lead +
              content_tag('div',
-               (options[:comments_link] ? link_to_comments(article) : '') +
-               (options[:read_more_link] ? reference_to_article( _('Read more'), article) : ''),
+               lead_links.html_safe,
                :class => 'read-more'
              ),
              :class => 'short-post'


=====================================
test/integration/safe_strings_test.rb
=====================================
--- a/test/integration/safe_strings_test.rb
+++ b/test/integration/safe_strings_test.rb
@@ -175,4 +175,15 @@ class SafeStringsTest < ActionDispatch::IntegrationTest
     assert_select '.icon-selector .icon-edit'
   end
 
+  should 'not escape read more link to article on display short format' do
+    profile = fast_create Profile
+    blog = fast_create Blog, :name => 'Blog', :profile_id => profile.id
+    fast_create(TinyMceArticle, :name => "Post Test", :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false, :body => '<p>Lorem ipsum dolor sit amet</p>')
+    blog.update_attribute(:visualization_format, 'short')
+
+    get "/#{profile.identifier}/blog"
+    assert_tag :tag => 'div', :attributes => {:class => 'read-more'}, :child => {:tag => 'a', :content => 'Read more'}
+  end
+
+
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/eb631713a254469a1979bc08344eba6cb1228115...4ed8d8c3bbaec4e4005fd3f4657b66a128de58f7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160607/962ccb06/attachment-0001.html>


More information about the Noosfero-dev mailing list