Merge branch 'fix/10918' into 'develop'

fix: escape ambiguous Mfm marks from html

Co-authored-by: Lhcfl <Lhcfl@outlook.com>

Closes #10918

See merge request firefish/firefish!10786
This commit is contained in:
naskya 2024-05-02 11:28:08 +00:00
commit 6e9ae06990

View file

@ -19,6 +19,13 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
return appendChildren(childNodes, background).join("").trim();
}
/**
* We only exclude text containing asterisks, since the other marks can almost be considered intentionally used.
*/
function escapeAmbiguousMfmMarks(text: string) {
return text.includes("*") ? `<plain>${text}</plain>` : text;
}
/**
* Get only the text, ignoring all formatting inside
* @param node
@ -62,7 +69,7 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
background = "",
): (string | string[])[] {
if (treeAdapter.isTextNode(node)) {
return [node.value];
return [escapeAmbiguousMfmMarks(node.value)];
}
// Skip comment or document type node