Skip to content

Conversation

@caugner
Copy link
Contributor

@caugner caugner commented Jan 12, 2026

Potential fix for https://github.com/mdn/content/security/code-scanning/56

In general, to fix incomplete multi-character sanitization with regex replacements, you can either (a) use a dedicated sanitization library, or (b) apply the replacement repeatedly until no further changes occur, ensuring that patterns that reappear after replacement are also removed. Here, the goal is very narrow—removing all HTML comments from a markdown file—so the simplest robust fix is to repeatedly apply the existing comment-stripping regex until the string stabilizes.

Concretely, in scripts/content/release-firefox.js, inside updateReleaseNotes, in the if (newStatus === "stable") block, the line:

content = content.replace(/<!--[\s\S]*?-->\n?/g, "");

should be replaced with a small loop that keeps applying this replacement until no more matches are found. This avoids any edge cases where removing one comment could create a new <!--...--> sequence that would otherwise be left behind. We don't need new imports or external libraries; just local logic in the same function. No other behavior of the script is changed.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions github-actions bot added the system [PR only] Infrastructure and configuration for the project label Jan 12, 2026
@caugner caugner changed the title Potential fix for code scanning alert no. 56: Incomplete multi-character sanitization chore(release-firefox): repeat sanitization Jan 12, 2026
@github-actions github-actions bot added the size/s [PR only] 6-50 LoC changed label Jan 12, 2026
@caugner caugner marked this pull request as ready for review January 12, 2026 14:28
@caugner caugner requested a review from a team as a code owner January 12, 2026 14:28
@caugner caugner requested review from bsmth and removed request for a team January 12, 2026 14:28
@bsmth bsmth requested review from pepelsbey and removed request for bsmth January 13, 2026 08:42
@pepelsbey
Copy link
Member

Given this script’s nature and use case, I’m not 100% sure there might be any user input risk here.

It’s just a comment in a markdown file we control.

So, I don’t want to overcomplicate code just to make the scanner happy based on an incorrect assumption.

@caugner
Copy link
Contributor Author

caugner commented Jan 13, 2026

@pepelsbey I think we should apply best practices, even in this case. Even if there is zero risk for us, folks might look at this code and take inspiration from it.

@pepelsbey
Copy link
Member

This code is not exposed either to MDN users or to MDN contributors and most likely will cease to exist with our plans for Firefox release notes. And I doubt that applying patterns irrelevant for the use case (we don’t have user input) is best practice. It’s more of a cargo cult. But it’s not a hill I’m willing to die on 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s [PR only] 6-50 LoC changed system [PR only] Infrastructure and configuration for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants