From 0834f87c5e29abdf0525c080c955effb2952ccc1 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Wed, 18 May 2016 14:52:07 -0300 Subject: [PATCH] not escape HTML from newsletter moderation tasks --- plugins/newsletter/test/integration/safe_strings_test.rb | 31 +++++++++++++++++++++++++++++++ plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb | 6 +++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 plugins/newsletter/test/integration/safe_strings_test.rb diff --git a/plugins/newsletter/test/integration/safe_strings_test.rb b/plugins/newsletter/test/integration/safe_strings_test.rb new file mode 100644 index 0000000..9d90f6e --- /dev/null +++ b/plugins/newsletter/test/integration/safe_strings_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class NewsletterPluginSafeStringsTest < ActionDispatch::IntegrationTest + + should 'not escape HTML from newsletter pending task' do + environment = Environment.default + environment.enable_plugin('newsletter') + person = create_user('john', :environment_id => environment.id, :password => 'test', :password_confirmation => 'test').person + person.user.activate + environment.add_admin(person) + + blog = fast_create(Blog, :profile_id => person.id) + post = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + newsletter = NewsletterPlugin::Newsletter.create!(:environment => environment, :person => person, :enabled => true) + newsletter.blog_ids = [blog.id] + newsletter.save! + task = NewsletterPlugin::ModerateNewsletter.create!( + :newsletter_id => newsletter.id, + :target => environment, + :post_ids => [post.id.to_s] + ) + + login 'john', 'test' + get '/myprofile/john/tasks' + + assert_tag :tag => 'input', + :attributes => { :type => 'checkbox', :name => "tasks[#{task.id}][task][post_ids][]" }, + :sibling => { :tag => 'span' } + end + +end diff --git a/plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb b/plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb index eca1d6e..750e66a 100644 --- a/plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb +++ b/plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb @@ -9,9 +9,9 @@ <% input_name = "tasks[#{task.id}][task][post_ids][]" %> <% post_check_box = hidden_field_tag(input_name, '0') +check_box_tag(input_name, post.id, true) %> - <% newsletter_content.gsub!(/]*?) id="#{post.id}"/, post_check_box + ' - <% newsletter_content.gsub!(/]*?) id="#{post.id}"/, post_check_box + ' + <% newsletter_content.gsub!(/]*?) id="#{post.id}"/, post_check_box + ' + <% newsletter_content.gsub!(/]*?) id="#{post.id}"/, post_check_box + ' <% end %> - <%= newsletter_content %> + <%= newsletter_content.html_safe %> -- libgit2 0.21.2