fix(site): resolve CodeQL ReDoS and incomplete escaping alerts (#5369)

* fix(scripts): remove ambiguous regex in co-author parsing (ReDoS)

The co-author trailer regex used \s+([^<]+)\s+< where both \s+ overlap
with [^<]+, giving polynomial backtracking on long whitespace runs.
\s([^<]+)\s< matches exactly the same strings and the same email group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9u8FhTjfkTLPkCeVkHN6p

* fix: escape all occurrences when sanitizing strings

- base64SVG: replace every newline, not just the first one
- createOGImage: escape & before < and > so tags aren't double-escaped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9u8FhTjfkTLPkCeVkHN6p

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Eric Fennis
2026-12-02 16:57:51 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 112d063fbd
commit 9ea275fb1f
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ export async function createIconOGImage(iconName: string, tags: string[]) {
const data = {
name: iconName,
tags: tags.join(' • ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/&/g, '&amp;'),
tags: tags.join(' • ').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'),
iconSVG,
};
+1 -1
View File
@@ -57,7 +57,7 @@ const getContributors = async (file: string, includeCoAuthors?: boolean) => {
}
if (includeCoAuthors) {
const matches = commit.body.matchAll(
/(^Author:|^Co-authored-by:)\s+(?<author>[^<]+)\s+<(?<email>[^>]+)>/gm,
/(^Author:|^Co-authored-by:)\s(?<author>[^<]+)\s<(?<email>[^>]+)>/gm,
);
for (const match of matches) {
+1 -1
View File
@@ -1,7 +1,7 @@
const base64SVG = (svgContents: string) =>
Buffer.from(
svgContents
.replace('\n', '')
.replaceAll('\n', '')
.replace(
'stroke="currentColor"',
'stroke="#000" style="background-color: #fff; border-radius: 2px"',