Another try at sanitize. (#1208)

* Sanitize again.

* Adding sanitize json function.

* Using serialize instead.
This commit is contained in:
Dessalines 2023-06-12 16:17:57 -04:00 committed by GitHub
parent de230a5e2f
commit a605c72859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View file

@ -4,7 +4,7 @@ set -e
new_tag="$1" new_tag="$1"
# Old deploy # Old deploy
# sudo docker build . --tag dessalines/lemmy-ui:$new_tag # sudo docker build . --tag dessalines/lemmy-ui:$new_tag --platform=linux/amd64
# sudo docker push dessalines/lemmy-ui:$new_tag # sudo docker push dessalines/lemmy-ui:$new_tag
# Upgrade version # Upgrade version

View file

@ -9,7 +9,6 @@ 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";
@ -348,7 +347,7 @@ async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) {
<!DOCTYPE html> <!DOCTYPE html>
<html ${helmet.htmlAttributes.toString()}> <html ${helmet.htmlAttributes.toString()}>
<head> <head>
<script>window.isoData = ${sanitize(JSON.stringify(isoData))}</script> <script>window.isoData = ${serialize(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 -->

View file

@ -207,12 +207,12 @@ export function hotRank(score: number, timeStr: string): number {
export function mdToHtml(text: string) { export function mdToHtml(text: string) {
// restore '>' character to fix quotes // restore '>' character to fix quotes
return { __html: md.render(text.split("&gt;").join(">")) }; return { __html: md.render(text) };
} }
export function mdToHtmlNoImages(text: string) { export function mdToHtmlNoImages(text: string) {
// restore '>' character to fix quotes // restore '>' character to fix quotes
return { __html: mdNoImages.render(text.split("&gt;").join(">")) }; return { __html: mdNoImages.render(text) };
} }
export function mdToHtmlInline(text: string) { export function mdToHtmlInline(text: string) {