diff --git a/app/assets/javascripts/pretty-text/emoji.js.es6 b/app/assets/javascripts/pretty-text/emoji.js.es6 index 1675e6e5e20..2946f35109b 100644 --- a/app/assets/javascripts/pretty-text/emoji.js.es6 +++ b/app/assets/javascripts/pretty-text/emoji.js.es6 @@ -64,7 +64,7 @@ export function buildEmojiUrl(code, opts) { url = opts.customEmoji[code]; } - const noToneMatch = code.match(/(.?[\w-]*)?:?/); + const noToneMatch = code.match(/([^:]+):?/); if (noToneMatch && !url && (emojiHash.hasOwnProperty(noToneMatch[1]) || aliasHash.hasOwnProperty(noToneMatch[1]))) { url = opts.getURL(`/images/emoji/${opts.emojiSet}/${code.replace(/:t/, '/')}.png`); } diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6 index 83814daafa0..02adc2cf1e0 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6 @@ -49,7 +49,7 @@ function rule(state, startLine, endLine) { let oldParentType = state.parentType; state.parentType = 'paragraph'; - token = state.push('paragraph_open', 'p', 0); + token = state.push('paragraph_open', 'p', 1); token.map = [startLine, state.line]; token = state.push('inline', '', 0); diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 778949b4dd1..4135ae6cfe1 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -561,19 +561,15 @@ describe PrettyText do html = <<~HTML

a

-

-
-

-

+


+

a

-

-

+

-

-

+

test
       
test
@@ -600,8 +596,7 @@ describe PrettyText do
     HTML
 
     html = <<~HTML
-      

-
+




@@ -661,6 +656,9 @@ describe PrettyText do expect(PrettyText.cook("hello 🤷‍♀️")).to eq("

hello \":woman_shrugging:\"

") end + it "should not treat a non emoji as an emoji" do + expect(PrettyText.cook(':email,class_name:')).not_to include('emoji') + end it "supports href schemes" do SiteSetting.allowed_href_schemes = "macappstore|steam" @@ -791,6 +789,7 @@ HTML expect(PrettyText.cook(" http://a.com")).not_to include('onebox') expect(PrettyText.cook("a\n http://a.com")).not_to include('onebox') expect(PrettyText.cook("sam@sam.com")).not_to include('onebox') + expect(PrettyText.cook("\nhttp://a.com")).to include('onebox') end it "can handle bbcode" do