fix: don't decode HTML entities (&foo;) until rendering (#465)

This commit is contained in:
Robert van Hoesel 2022-12-20 01:23:06 +01:00 committed by GitHub
parent 9a7c37db24
commit f8ebc0e99a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View file

@ -4,7 +4,7 @@ import type { Node } from 'ultrahtml'
import { Fragment, h, isVNode } from 'vue'
import type { VNode } from 'vue'
import { RouterLink } from 'vue-router'
import { parseMastodonHTML } from './content-parse'
import { decodeHtml, parseMastodonHTML } from './content-parse'
import ContentCode from '~/components/content/ContentCode.vue'
import AccountHoverWrapper from '~/components/account/AccountHoverWrapper.vue'
@ -45,11 +45,12 @@ export function nodeToVNode(node: Node): VNode | string | null {
}
return null
}
function treeToVNode(
input: Node,
): VNode | string | null {
if (input.type === TEXT_NODE)
return input.value as string
return decodeHtml(input.value)
if ('children' in input) {
const node = handleNode(input)