diff --git a/plugins/poll/assets/javascripts/poll_dialect.js b/plugins/poll/assets/javascripts/poll_dialect.js index 126f483314c..d2e0b4c93c1 100644 --- a/plugins/poll/assets/javascripts/poll_dialect.js +++ b/plugins/poll/assets/javascripts/poll_dialect.js @@ -8,10 +8,10 @@ const WHITELISTED_ATTRIBUTES = ["type", "name", "min", "max", "step", "order", "color", "background", "status"]; const WHITELISTED_STYLES = ["color", "background"]; - const ATTRIBUTES_REGEX = new RegExp("(" + WHITELISTED_ATTRIBUTES.join("|") + ")=['\"]?[^\\s\\]=]+['\"]?", "g"); + const ATTRIBUTES_REGEX = new RegExp("(" + WHITELISTED_ATTRIBUTES.join("|") + ")=['\"]?[^\\s\\]]+['\"]?", "g"); Discourse.Dialect.replaceBlock({ - start: /\[poll([^\]]*)\]([\s\S]*)/igm, + start: /\[poll((?:\s+\w+=[^\s\]]+)*)\]([\s\S]*)/igm, stop: /\[\/poll\]/igm, emitter: function(blockContents, matches) { diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb index 3d63d8425bc..ad373624ceb 100644 --- a/plugins/poll/spec/controllers/posts_controller_spec.rb +++ b/plugins/poll/spec/controllers/posts_controller_spec.rb @@ -57,6 +57,14 @@ describe PostsController do expect(json["polls"]["<script>alert(xss)</script>"]).to be end + it "also works whe there is a link starting with '[poll'" do + xhr :post, :create, { title: title, raw: "[Polls are awesome](/foobar)\n[poll]\n- A\n- B\n[/poll]" } + expect(response).to be_success + json = ::JSON.parse(response.body) + expect(json["cooked"]).to match("data-poll-") + expect(json["polls"]).to be + end + describe "edit window" do describe "within the first 5 minutes" do