From 40abcfc2f55c632fd5db65cef4e20ca0a1090063 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Jul 2017 12:21:49 -0400 Subject: [PATCH] FIX: smart quote edge case with quotes --- .../engines/discourse-markdown/bbcode-block.js.es6 | 4 ++-- spec/components/pretty_text_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6 index cd1620bcae..8c4ac0e280 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6 @@ -11,7 +11,7 @@ function trailingSpaceOnly(src, start, max) { return true; } -const ATTR_REGEX = /((([a-z0-9]*)\s*)=)(["'].*["']|\S+)/ig; +const ATTR_REGEX = /((([a-z0-9]*)\s*)=)(["“”'].*["“”']|\S+)/ig; // parse a tag [test a=1 b=2] to a data structure // {tag: "test", attrs={a: "1", b: "2"} @@ -85,7 +85,7 @@ export function parseBBCodeTag(src, start, max, multiline) { if (val) { val = val.trim(); - val = val.replace(/^["'](.*)["']$/, '$1'); + val = val.replace(/^["'“”](.*)["'“”]$/, '$1'); attrs[key] = val; } } diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 9f587060f6..6175a1e120 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -52,9 +52,9 @@ describe PrettyText do expect(cook("[quote=\"EvilTrout, post:2, topic:#{topic.id}\"]\nddd\n[/quote]", topic_id: 1)).to eq(n(expected)) end - it "produces a quote even with new lines in it" do + it "indifferent about curlies" do md = <<~MD - [quote="#{user.username}, post:123, topic:456, full:true"] + [quote=“#{user.username}, post:123, topic:456, full:true”] ddd