From 03b0d6d30b878a36477c8b4a58725b69914f65e2 Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 19 Nov 2024 12:08:49 +0700 Subject: [PATCH] fix: sanitize pds versioning --- scripts/generate-markdown.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/generate-markdown.ts b/scripts/generate-markdown.ts index 82ed864..33e6935 100644 --- a/scripts/generate-markdown.ts +++ b/scripts/generate-markdown.ts @@ -95,7 +95,7 @@ Instances that have not been active for more than 7 days gets dropped off from t const { errorAt, inviteCodeRequired, version } = info; const on = errorAt === undefined ? '✅' : '❌'; - const v = version || (version === null ? 'N/A' : '???'); + const v = version ? heavilySanitize(version) : version === null ? 'N/A' : '???'; const invites = inviteCodeRequired === false ? 'Yes' : 'No'; if (isBlueskyHost(host)) { @@ -111,7 +111,7 @@ Instances that have not been active for more than 7 days gets dropped off from t const { errorAt, version } = info; const on = errorAt === undefined ? '✅' : '❌'; - const v = version || (version === null ? 'N/A' : '???'); + const v = version ? heavilySanitize(version) : version === null ? 'N/A' : '???'; if (isBlueskyHost(host)) { labelerBskyTable += `| ${on} ${host} | ${v} |\n`; @@ -221,4 +221,8 @@ Instances that have not been active for more than 7 days gets dropped off from t function isBlueskyHost(host: string): boolean { return /(?:^|\.)(?:bsky\.network|bsky\.app|bsky\.dev|bsky\.social)$/.test(host); } + + function heavilySanitize(str: string): string { + return str.replace(/([\\`*_{}\[\]()#+!])/g, '\\$1'); + } }