mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-24 07:16:19 +00:00
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
This commit is contained in:
parent
50a8f40187
commit
4867e455f8
|
@ -9,6 +9,7 @@ import IsomorphicCookie from "isomorphic-cookie";
|
||||||
import { GetSite, GetSiteResponse, LemmyHttp, Site } from "lemmy-js-client";
|
import { GetSite, GetSiteResponse, LemmyHttp, Site } from "lemmy-js-client";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
import sanitize from "sanitize-html";
|
||||||
import serialize from "serialize-javascript";
|
import serialize from "serialize-javascript";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { App } from "../shared/components/app/app";
|
import { App } from "../shared/components/app/app";
|
||||||
|
@ -25,7 +26,6 @@ import {
|
||||||
favIconUrl,
|
favIconUrl,
|
||||||
initializeSite,
|
initializeSite,
|
||||||
isAuthPath,
|
isAuthPath,
|
||||||
md,
|
|
||||||
} from "../shared/utils";
|
} from "../shared/utils";
|
||||||
|
|
||||||
const server = express();
|
const server = express();
|
||||||
|
@ -348,9 +348,7 @@ async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html ${helmet.htmlAttributes.toString()} lang="en">
|
<html ${helmet.htmlAttributes.toString()} lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script>window.isoData = ${md.utils.escapeHtml(
|
<script>window.isoData = ${sanitize(JSON.stringify(isoData))}</script>
|
||||||
JSON.stringify(isoData)
|
|
||||||
)}</script>
|
|
||||||
<script>window.lemmyConfig = ${serialize(config)}</script>
|
<script>window.lemmyConfig = ${serialize(config)}</script>
|
||||||
|
|
||||||
<!-- A remote debugging utility for mobile -->
|
<!-- A remote debugging utility for mobile -->
|
||||||
|
|
|
@ -206,11 +206,13 @@ export function hotRank(score: number, timeStr: string): number {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mdToHtml(text: string) {
|
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) {
|
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) {
|
export function mdToHtmlInline(text: string) {
|
||||||
|
|
Loading…
Reference in a new issue