[Git][noosfero/noosfero][master] 2 commits: fixed html safe problems.

Leandro Nunes gitlab at mg.gitlab.com
Mon Sep 12 11:27:08 BRT 2016


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
641cf7e9 by Gustavo Cavalcante at 2016-09-12T09:17:56-03:00
fixed html safe problems.

Signed-off-by: Gustavo Cavalcante <gustavo.cavalcante.oliveira at live.com>
Signed-off-by: Karine Valença <valenca.karine at gmail.com>

- - - - -
42e47bc4 by Leandro Nunes at 2016-09-12T14:25:23+00:00
Merge branch 'issue1_htmlsafe' into 'master'

fixed html safe problems.

Fixed some html_safe problems of the field sex when visiting profile and added related test.
Also fixed html_safe problem related to a title of a event and added related test.

See merge request !1018
- - - - -


3 changed files:

- app/helpers/application_helper.rb
- app/helpers/search_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
@@ -518,8 +518,6 @@ module ApplicationHelper
       html = "\n"
       values.each { |val, h_val|
         id = object_name.to_s() +'_'+ method.to_s() +'_'+ val.to_s()
-        # Não está apresentando o sexo selecionado ao revisitar
-        # http://localhost:3000/myprofile/manuel/profile_editor/edit  :-(
         html += self.class.content_tag( 'span',
             @template.radio_button( object_name, method, val,
                                     :id => id, :object => @object ) +
@@ -530,6 +528,7 @@ module ApplicationHelper
           html += "<br />\n".html_safe
         end
       }
+      html = html.html_safe
       html += "<br />\n".html_safe if line_size == 0 || ( values.size % line_size ) > 0
       column = object.class.columns_hash[method.to_s] if object
       text =


=====================================
app/helpers/search_helper.rb
=====================================
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -45,7 +45,8 @@ module SearchHelper
   def search_page_title(title, category = nil)
     title = "<h1>" + title
     title += ' - <small>' + category.name + '</small>' if category
-    title + "</h1>"
+    title += "</h1>"
+    title.html_safe
   end
 
   def category_context(category, url)


=====================================
test/integration/safe_strings_test.rb
=====================================
--- a/test/integration/safe_strings_test.rb
+++ b/test/integration/safe_strings_test.rb
@@ -185,5 +185,14 @@ class SafeStringsTest < ActionDispatch::IntegrationTest
     assert_tag :tag => 'div', :attributes => {:class => 'read-more'}, :child => {:tag => 'a', :content => 'Read more'}
   end
 
+  should 'not scape sex radio button' do
+    env = Environment.default
+    env.custom_person_fields = { 'sex' => { 'active' => 'true' } }
+    env.save!
+    create_user('marley', :password => 'test', :password_confirmation => 'test').activate
+    login 'marley', 'test'
+    get "/myprofile/marley/profile_editor/edit"
+    assert_tag :tag => 'input', :attributes => { :id => "profile_data_sex_male" }
+  end
 
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/4daba0e28073dbacbd58ec88bc2db27217e6b7c7...42e47bc418aafd565d9efeb2e5ef7232eb0de40e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160912/e26b8fdb/attachment-0001.html>


More information about the Noosfero-dev mailing list