From cd5644d6d27f06c3bd4f6ae8c4862303dbc4f147 Mon Sep 17 00:00:00 2001 From: taisei <46064673+taisei-86@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:58:13 +0900 Subject: [PATCH] Remove markdown with meta tags (#4968) Co-authored-by: Frank Elsinga --- server/model/status_page.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/model/status_page.js b/server/model/status_page.js index 528d1dd49..e40b28f6f 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -4,6 +4,7 @@ const cheerio = require("cheerio"); const { UptimeKumaServer } = require("../uptime-kuma-server"); const jsesc = require("jsesc"); const googleAnalytics = require("../google-analytics"); +const { marked } = require("marked"); class StatusPage extends BeanModel { @@ -46,7 +47,11 @@ class StatusPage extends BeanModel { */ static async renderHTML(indexHTML, statusPage) { const $ = cheerio.load(indexHTML); - const description155 = statusPage.description?.substring(0, 155) ?? ""; + + const description155 = marked(statusPage.description ?? "") + .replace(/<[^>]+>/gm, "") + .trim() + .substring(0, 155); $("title").text(statusPage.title); $("meta[name=description]").attr("content", description155);