From c139c8110c0f3ea49d9a453a91ce85da24faf0d3 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 18 Jun 2021 21:42:46 +0300 Subject: [PATCH] fix not escaping some stuff --- src/components/rich_content/rich_content.jsx | 13 ++++------- .../specs/components/rich_content.spec.js | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index ce562f13..79acd1de 100644 --- a/src/components/rich_content/rich_content.jsx +++ b/src/components/rich_content/rich_content.jsx @@ -121,14 +121,13 @@ export default Vue.component('RichContent', { if (emptyText) { return encounteredText ? item : item.trim() } - let unescapedItem = unescape(item) if (!encounteredText) { - unescapedItem = unescapedItem.trimStart() + item = item.trimStart() encounteredText = true } if (item.includes(':')) { - unescapedItem = ['', processTextForEmoji( - unescapedItem, + item = ['', processTextForEmoji( + item, this.emoji, ({ shortcode, url }) => { return { newChildren } diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js index 96c480ea..fbf8973d 100644 --- a/test/unit/specs/components/rich_content.spec.js +++ b/test/unit/specs/components/rich_content.spec.js @@ -27,6 +27,29 @@ describe('RichContent', () => { expect(wrapper.html()).to.eql(compwrap(html)) }) + it('unescapes everything as needed', () => { + const html = [ + p('Testing 'em all'), + 'Testing 'em all' + ].join('') + const expected = [ + p('Testing \'em all'), + 'Testing \'em all' + ].join('') + const wrapper = shallowMount(RichContent, { + localVue, + propsData: { + hideMentions: true, + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(expected)) + }) + it('removes mentions from the beginning of post', () => { const html = p( makeMention('John'),