From 5fe0ca791317a3b609a20382ca5409152f741263 Mon Sep 17 00:00:00 2001
From: Nafees Nazik <84864519+G3root@users.noreply.github.com>
Date: Fri, 3 Mar 2023 01:25:57 +0530
Subject: [PATCH] fix: escape markdown in users OG image (#7474)
* fix: escape markdown in bio
* chore: add remark and strip-markdown package
* feat: strip markdown
* fix: remove first commit
---
apps/web/package.json | 2 ++
apps/web/pages/api/social/og/image.tsx | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/apps/web/package.json b/apps/web/package.json
index ac6ad5d55e..59c0ac169b 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -116,9 +116,11 @@
"react-use-intercom": "1.5.1",
"react-virtualized-auto-sizer": "^1.0.6",
"react-window": "^1.8.7",
+ "remark": "^14.0.2",
"rrule": "^2.7.1",
"schema-dts": "^1.1.0",
"short-uuid": "^4.2.0",
+ "strip-markdown": "^5.0.0",
"stripe": "^9.16.0",
"superjson": "1.9.1",
"tailwindcss-radix": "^2.6.0",
diff --git a/apps/web/pages/api/social/og/image.tsx b/apps/web/pages/api/social/og/image.tsx
index 87744b3b2c..c37f0a0284 100644
--- a/apps/web/pages/api/social/og/image.tsx
+++ b/apps/web/pages/api/social/og/image.tsx
@@ -1,6 +1,8 @@
import { ImageResponse } from "@vercel/og";
import type { NextApiRequest } from "next";
+import { remark } from "remark";
import type { SatoriOptions } from "satori";
+import strip from "strip-markdown";
import { z } from "zod";
import { Meeting, App, Generic } from "@calcom/lib/OgImages";
@@ -106,8 +108,8 @@ export default async function handler(req: NextApiRequest) {
description: searchParams.get("description"),
imageType,
});
-
- const img = new ImageResponse(, ogConfig) as {
+ const description_ = await (await remark().use(strip).process(description)).toString();
+ const img = new ImageResponse(, ogConfig) as {
body: Buffer;
};