diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb index 4903f762b3b..2bf54226e3f 100644 --- a/plugins/poll/plugin.rb +++ b/plugins/poll/plugin.rb @@ -157,14 +157,14 @@ after_initialize do # extract attributes p.attributes.values.each do |attribute| if attribute.name.start_with?(DATA_PREFIX) - poll[attribute.name[DATA_PREFIX.length..-1]] = CGI::escapeHTML(attribute.value || "") + poll[attribute.name[DATA_PREFIX.length..-1]] = CGI.escapeHTML(attribute.value || "") end end # extract options p.css("li[#{DATA_PREFIX}option-id]").each do |o| - option_id = CGI::escapeHTML(o.attributes[DATA_PREFIX + "option-id"].value || "") - poll["options"] << { "id" => option_id, "html" => CGI::escapeHTML(o.inner_html), "votes" => 0 } + option_id = o.attributes[DATA_PREFIX + "option-id"].value || "" + poll["options"] << { "id" => option_id, "html" => o.inner_html, "votes" => 0 } end # add the poll diff --git a/plugins/poll/spec/lib/pretty_text_spec.rb b/plugins/poll/spec/lib/pretty_text_spec.rb index 35bbd18530d..85ee2c2a00e 100644 --- a/plugins/poll/spec/lib/pretty_text_spec.rb +++ b/plugins/poll/spec/lib/pretty_text_spec.rb @@ -7,124 +7,122 @@ describe PrettyText do HtmlNormalize.normalize(html) end - context 'markdown it' do - it 'supports multi choice polls' do - cooked = PrettyText.cook <<~MD - [poll type=multiple min=1 max=3 public=true] - * option 1 - * option 2 - * option 3 - [/poll] - MD + it 'supports multi choice polls' do + cooked = PrettyText.cook <<~MD + [poll type=multiple min=1 max=3 public=true] + * option 1 + * option 2 + * option 3 + [/poll] + MD - expect(cooked).to include('class="poll"') - expect(cooked).to include('data-poll-status="open"') - expect(cooked).to include('data-poll-name="poll"') - expect(cooked).to include('data-poll-type="multiple"') - expect(cooked).to include('data-poll-min="1"') - expect(cooked).to include('data-poll-max="3"') - expect(cooked).to include('data-poll-public="true"') - end + expect(cooked).to include('class="poll"') + expect(cooked).to include('data-poll-status="open"') + expect(cooked).to include('data-poll-name="poll"') + expect(cooked).to include('data-poll-type="multiple"') + expect(cooked).to include('data-poll-min="1"') + expect(cooked).to include('data-poll-max="3"') + expect(cooked).to include('data-poll-public="true"') + end - it 'can dynamically generate a poll' do + it 'can dynamically generate a poll' do - cooked = PrettyText.cook <<~MD - [poll type=number min=1 max=20 step=1] - [/poll] - MD + cooked = PrettyText.cook <<~MD + [poll type=number min=1 max=20 step=1] + [/poll] + MD - expect(cooked.scan('
- 0 - voters -
-- Choose up to 2 options
-+ 0 + voters +
++ Choose up to 2 options
+