Skip to content

Commit

Permalink
fix: sanitize properly god
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-ext committed Nov 20, 2024
1 parent a69856d commit 4dfcbbd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/generate-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? heavilySanitize(version) : version === null ? 'N/A' : '???';
const v = version ? sanitize(version) : version === null ? 'N/A' : '???';
const invites = inviteCodeRequired === false ? 'Yes' : 'No';

if (isBlueskyHost(host)) {
Expand All @@ -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 ? heavilySanitize(version) : version === null ? 'N/A' : '???';
const v = version ? sanitize(version) : version === null ? 'N/A' : '???';

if (isBlueskyHost(host)) {
labelerBskyTable += `| ${on} ${host} | ${v} |\n`;
Expand Down Expand Up @@ -222,7 +222,7 @@ Instances that have not been active for more than 7 days gets dropped off from t
return /(?:^|\.)(?:bsky\.network|bsky\.app|bsky\.dev|bsky\.social)$/.test(host);
}

function heavilySanitize(str: string): string {
return str.replace(/([\\`*_{}\[\]()#+!])/g, '\\$1');
function sanitize(str: string): string {
return str.replace(/[^ a-zA-Z0-9-_=+.,:;!`'"<>()\[\]/\\]/g, '').replace(/([<\\\[!`]|(?<=\s)[_])/g, '\\$1');
}
}

0 comments on commit 4dfcbbd

Please sign in to comment.