fix not escaping some stuff
This commit is contained in:
parent
8fe4355a6b
commit
c6831a3810
@ -121,14 +121,13 @@ export default Vue.component('RichContent', {
|
|||||||
if (emptyText) {
|
if (emptyText) {
|
||||||
return encounteredText ? item : item.trim()
|
return encounteredText ? item : item.trim()
|
||||||
}
|
}
|
||||||
let unescapedItem = unescape(item)
|
|
||||||
if (!encounteredText) {
|
if (!encounteredText) {
|
||||||
unescapedItem = unescapedItem.trimStart()
|
item = item.trimStart()
|
||||||
encounteredText = true
|
encounteredText = true
|
||||||
}
|
}
|
||||||
if (item.includes(':')) {
|
if (item.includes(':')) {
|
||||||
unescapedItem = ['', processTextForEmoji(
|
item = ['', processTextForEmoji(
|
||||||
unescapedItem,
|
item,
|
||||||
this.emoji,
|
this.emoji,
|
||||||
({ shortcode, url }) => {
|
({ shortcode, url }) => {
|
||||||
return <StillImage
|
return <StillImage
|
||||||
@ -140,7 +139,7 @@ export default Vue.component('RichContent', {
|
|||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
return unescapedItem
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle tag nodes
|
// Handle tag nodes
|
||||||
@ -189,7 +188,7 @@ export default Vue.component('RichContent', {
|
|||||||
const emptyText = item.trim() === ''
|
const emptyText = item.trim() === ''
|
||||||
if (emptyText) return item
|
if (emptyText) return item
|
||||||
if (!encounteredTextReverse) encounteredTextReverse = true
|
if (!encounteredTextReverse) encounteredTextReverse = true
|
||||||
return item
|
return unescape(item)
|
||||||
} else if (Array.isArray(item)) {
|
} else if (Array.isArray(item)) {
|
||||||
// Handle tag nodes
|
// Handle tag nodes
|
||||||
const [opener, children] = item
|
const [opener, children] = item
|
||||||
@ -203,9 +202,7 @@ export default Vue.component('RichContent', {
|
|||||||
return renderHashtag(attrs, children, encounteredTextReverse)
|
return renderHashtag(attrs, children, encounteredTextReverse)
|
||||||
} else {
|
} else {
|
||||||
attrs.target = '_blank'
|
attrs.target = '_blank'
|
||||||
html.includes('freenode') && console.log('PASS1', children)
|
|
||||||
const newChildren = [...children].reverse().map(processItemReverse).reverse()
|
const newChildren = [...children].reverse().map(processItemReverse).reverse()
|
||||||
html.includes('freenode') && console.log('PASS1b', newChildren)
|
|
||||||
|
|
||||||
return <a {...{ attrs }}>
|
return <a {...{ attrs }}>
|
||||||
{ newChildren }
|
{ newChildren }
|
||||||
|
@ -27,6 +27,29 @@ describe('RichContent', () => {
|
|||||||
expect(wrapper.html()).to.eql(compwrap(html))
|
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', () => {
|
it('removes mentions from the beginning of post', () => {
|
||||||
const html = p(
|
const html = p(
|
||||||
makeMention('John'),
|
makeMention('John'),
|
||||||
|
Loading…
Reference in New Issue
Block a user