From: Nutomic Date: Fri, 9 Jun 2023 12:17:02 +0000 (+0200) Subject: Alternative way to sanitize isoData (#1129) X-Git-Url: http://these/git/readmes/%24%7B%60data:application/static/%7BpictshareAvatarThumbnail%28?a=commitdiff_plain;h=4867e455f80525306ca9aef9c59fea0a6bd1b4c5;p=lemmy-ui.git Alternative way to sanitize isoData (#1129) * Alternative way to sanitize isoData * use split/join instead of replaceAll * Use sanitize, then restore > chars for markdown render --- diff --git a/src/server/index.tsx b/src/server/index.tsx index f96901b..1fab13d 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -9,6 +9,7 @@ import IsomorphicCookie from "isomorphic-cookie"; import { GetSite, GetSiteResponse, LemmyHttp, Site } from "lemmy-js-client"; import path from "path"; import process from "process"; +import sanitize from "sanitize-html"; import serialize from "serialize-javascript"; import sharp from "sharp"; import { App } from "../shared/components/app/app"; @@ -25,7 +26,6 @@ import { favIconUrl, initializeSite, isAuthPath, - md, } from "../shared/utils"; const server = express(); @@ -348,9 +348,7 @@ async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) { - + diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 504bfcb..2934268 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -206,11 +206,13 @@ export function hotRank(score: number, timeStr: string): number { } export function mdToHtml(text: string) { - return { __html: md.render(text) }; + // restore '>' character to fix quotes + return { __html: md.render(text).split(">").join(">") }; } export function mdToHtmlNoImages(text: string) { - return { __html: mdNoImages.render(text) }; + // restore '>' character to fix quotes + return { __html: mdNoImages.render(text).split(">").join(">") }; } export function mdToHtmlInline(text: string) {