diff --git a/src/client/index.tsx b/src/client/index.tsx index 7fea2c69..7b6b6b1c 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -7,7 +7,7 @@ import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; import { HistoryService } from "../shared/services/HistoryService"; -const site = JSON.parse(window.isoData).site_res; +const site = window.isoData.site_res; initializeSite(site); const wrapper = ( diff --git a/src/server/index.tsx b/src/server/index.tsx index 73b3d7a1..8aacba9f 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"; @@ -353,8 +354,8 @@ async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) { - - + + ${erudaStr} diff --git a/src/shared/interfaces.ts b/src/shared/interfaces.ts index 0d846d82..3b64f605 100644 --- a/src/shared/interfaces.ts +++ b/src/shared/interfaces.ts @@ -22,7 +22,7 @@ export interface ILemmyConfig { declare global { interface Window { - isoData: string; + isoData: IsoData; lemmyConfig?: ILemmyConfig; } } diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 870bed72..8339a1ad 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -204,11 +204,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.replace(/>/g, ">")) }; } export function mdToHtmlNoImages(text: string) { - return { __html: mdNoImages.render(text) }; + // restore '>' character to fix quotes + return { __html: mdNoImages.render(text.replace(/>/g, ">")) }; } export function mdToHtmlInline(text: string) { @@ -1164,7 +1166,7 @@ export function isBrowser() { export function setIsoData(context: any): IsoData { // If its the browser, you need to deserialize the data from the window if (isBrowser()) { - return JSON.parse(window.isoData); + return window.isoData; } else return context.router.staticContext; }