diff --git a/app/assets/javascripts/pretty-text/engines/markdown-it/bbcode-block.js.es6 b/app/assets/javascripts/pretty-text/engines/markdown-it/bbcode-block.js.es6 index 8e76449b3f7..ff8860c688c 100644 --- a/app/assets/javascripts/pretty-text/engines/markdown-it/bbcode-block.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/markdown-it/bbcode-block.js.es6 @@ -96,7 +96,6 @@ function applyBBCode(state, startLine, endLine, silent, md) { initial = start, max = state.eMarks[startLine]; - // [ === 91 if (91 !== state.src.charCodeAt(start)) { return false; } @@ -128,9 +127,8 @@ function applyBBCode(state, startLine, endLine, silent, md) { for (;;) { nextLine++; if (nextLine >= endLine) { - // unclosed block should be autoclosed by end of document. - // also block seems to be autoclosed by end of parent - break; + // unclosed bbcode block should not be autoclosed by end of document. + return false; } start = state.bMarks[nextLine] + state.tShift[nextLine]; diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 468251d7329..40beccda495 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -22,7 +22,7 @@ describe PrettyText do topic = Fabricate(:topic, title: "this is a test topic :slight_smile:") expected = <
HTML @@ -298,17 +298,17 @@ HTML end it "should have an option to preserve emoji images" do - emoji_image = "" + emoji_image = "" expect(PrettyText.excerpt(emoji_image, 100, { keep_emoji_images: true })).to match_html(emoji_image) end it "should have an option to remap emoji to code points" do - emoji_image = "I you " + emoji_image = "I you " expect(PrettyText.excerpt(emoji_image, 100, { remap_emoji: true })).to match_html("I ❤ you :unknown:") end it "should have an option to preserve emoji codes" do - emoji_code = "" + emoji_code = "" expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:") end @@ -463,10 +463,10 @@ HTML end it "replaces skin toned emoji" do - expect(PrettyText.cook("hello 👱🏿♀️")).to eq("ddd
hello
") - expect(PrettyText.cook("hello 👩🎤")).to eq("hello
") - expect(PrettyText.cook("hello 👩🏾🎓")).to eq("hello
") - expect(PrettyText.cook("hello 🤷♀️")).to eq("hello
") + expect(PrettyText.cook("hello 👱🏿♀️")).to eq("hello
") + expect(PrettyText.cook("hello 👩🎤")).to eq("hello
") + expect(PrettyText.cook("hello 👩🏾🎓")).to eq("hello
") + expect(PrettyText.cook("hello 🤷♀️")).to eq("hello
") end end @@ -564,19 +564,19 @@ HTML it "can handle emoji by name" do expected = < + HTML expect(PrettyText.cook(":smile::sunny:")).to eq(expected.strip) end it "handles emoji boundaries correctly" do cooked = PrettyText.cook("a,:man:t2:,b") - expected = 'a,,b
' + expected = 'a,,b
' expect(cooked).to match(expected.strip) end it "can handle emoji by translation" do - expected = '' + expected = '' expect(PrettyText.cook(";)")).to eq(expected) end @@ -636,6 +636,12 @@ HTML expect(PrettyText.cook("a[i]b[/i]c")).to eq('abc
') end + it "can handle quote edge cases" do + # expect(cook("a\n[quote]\ntest\n[quote]")).to include('aside') + expect(cook("[quote]\ntest")).not_to include('aside') + # expect(cook("[quote]abc\ntest\n[quote]")).not_to include('aside') + end + it "do off topic quoting with emoji unescape" do topic = Fabricate(:topic, title: "this is a test topic :slight_smile:") @@ -643,7 +649,7 @@ HTML