Skip to content

fix: escape regex metacharacters when building changelog link pattern#337

Open
adonesky1 wants to merge 1 commit into
mainfrom
fix/escape-regex-changelog-pattern
Open

fix: escape regex metacharacters when building changelog link pattern#337
adonesky1 wants to merge 1 commit into
mainfrom
fix/escape-regex-changelog-pattern

Conversation

@adonesky1

Copy link
Copy Markdown
Contributor

Description

Resolves CodeQL js/incomplete-sanitization (high) in scripts/bump-dependent-playgrounds.ts.

packageName is interpolated into a dynamically-constructed RegExp, but it was only run through .replace(/\//gu, '\\/') — which escapes forward slashes and leaves backslashes and other regex metacharacters unescaped. This replaces the ad-hoc escape with a proper escapeRegExp helper.

This is a pre-existing issue on main (independent of the repo rename in #267). Splitting it out into its own PR so the rename PR stays scoped to the rename.

Changes

  • Add an escapeRegExp(value) helper that escapes all regex metacharacters.
  • Use it for packageName when building the [Unreleased] link pattern.

Behavior is unchanged for real package names (e.g. @metamask/analytics), which contain no regex metacharacters.

Notes

  • No functional change to the changelog-bumping output.
  • eslint passes (verified via the pre-commit hook).

Resolves CodeQL js/incomplete-sanitization (high) in
bump-dependent-playgrounds.ts. packageName was interpolated into a
dynamically-constructed RegExp after escaping only forward slashes,
leaving backslashes and other regex metacharacters unescaped. Replace
the ad-hoc .replace with a proper escapeRegExp helper.
@adonesky1 adonesky1 requested a review from a team as a code owner June 24, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants