Skip to content

Potential fix for code scanning alert no. 2: Incomplete multi-character sanitization#4

Closed
PRATHAM777P wants to merge 1 commit into
mainfrom
alert-autofix-2
Closed

Potential fix for code scanning alert no. 2: Incomplete multi-character sanitization#4
PRATHAM777P wants to merge 1 commit into
mainfrom
alert-autofix-2

Conversation

@PRATHAM777P
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/PRATHAM777P/AlphaMind/security/code-scanning/2

Use a fixed-point (repeat-until-unchanged) removal for <script>, <style>, and <noscript> blocks, instead of one-pass chained replacements. This directly addresses reappearance/overlap cases without changing intended functionality.

Best fix in this file:

  • Add a helper that repeatedly applies the existing block-removal regexes until no further changes occur.
  • Replace the one-pass initialization of text in htmlToMarkdown (lines 38–41 region) with a call to that helper.

This keeps behavior consistent for normal input while closing the incomplete multi-character sanitization gap CodeQL identified.

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>
@PRATHAM777P PRATHAM777P marked this pull request as ready for review April 27, 2026 18:16
Comment on lines +40 to +42
current = current
.replace(/<script[\s\S]*?<\/script>/gi, "")
.replace(/<style[\s\S]*?<\/style>/gi, "")
Comment on lines +40 to +41
current = current
.replace(/<script[\s\S]*?<\/script>/gi, "")
do {
previous = current;
current = current
.replace(/<script[\s\S]*?<\/script>/gi, "")
@PRATHAM777P PRATHAM777P deleted the alert-autofix-2 branch April 27, 2026 18:23
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