Skip to content

Potential fix for code scanning alert no. 1: Incomplete multi-character sanitization - #3

Merged
f1anderz merged 3 commits into
mainfrom
alert-autofix-1
Jul 27, 2026
Merged

Potential fix for code scanning alert no. 1: Incomplete multi-character sanitization#3
f1anderz merged 3 commits into
mainfrom
alert-autofix-1

Conversation

@f1anderz

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/f1anderz/msg-parser/security/code-scanning/1

Use a fixed-point sanitization loop: repeatedly apply the same three replacements until the string no longer changes. This preserves existing behavior while ensuring that any newly exposed on...= (or other targeted patterns) produced by earlier replacements is also removed.

In src/html/sanitize.ts, update sanitizeHtml only:

  • Replace the current chained one-pass return html.replace(...).replace(...).replace(...);
  • With a do...while loop that:
    • stores previous value,
    • applies the same replacement chain to a working variable,
    • repeats until stable,
    • returns the stabilized result.

No new imports or dependencies are required.

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

…er sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread src/html/sanitize.ts Fixed
Comment thread src/html/sanitize.ts Fixed
Comment thread src/html/sanitize.ts Fixed
…racter sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread src/html/sanitize.ts Fixed
Comment thread src/html/sanitize.ts Fixed
Comment thread src/html/sanitize.ts Fixed
…egexp'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread src/html/sanitize.ts Dismissed
Comment thread src/html/sanitize.ts Dismissed
Comment thread src/html/sanitize.ts Dismissed
@f1anderz
f1anderz marked this pull request as ready for review July 27, 2026 15:48
@f1anderz
f1anderz merged commit e2cff72 into main Jul 27, 2026
4 checks passed
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