Skip to content

Potential fix for code scanning alert no. 6: DOM text reinterpreted as HTML#26

Merged
vannu07 merged 1 commit intomainfrom
alert-autofix-6
Oct 21, 2025
Merged

Potential fix for code scanning alert no. 6: DOM text reinterpreted as HTML#26
vannu07 merged 1 commit intomainfrom
alert-autofix-6

Conversation

@vannu07
Copy link
Copy Markdown
Owner

@vannu07 vannu07 commented Oct 21, 2025

Potential fix for https://github.com/vannu07/jarvis/security/code-scanning/6

To fix the issue, all text coming from the DOM (via t.text()) should be escaped before being added as HTML content using string concatenation and .append(). The best way is to properly encode the item variable before concatenation in line 18, so HTML metacharacters are converted to entities (e.g., < becomes &lt;). In jQuery, a common approach is to use document.createTextNode to escape text, but since we are building HTML as a string, we need an explicit escaping function.

  • Add an escape function to convert metacharacters to their HTML entity forms.
  • Use this function to escape item before concatenating.
  • All edits must be inside the relevant code you have been shown.

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

…s HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message that will be displayed on users' first pull request

@vannu07 vannu07 marked this pull request as ready for review October 21, 2025 11:25
@vannu07 vannu07 merged commit bfc2e7a into main Oct 21, 2025
9 checks passed
@vannu07 vannu07 deleted the alert-autofix-6 branch October 21, 2025 11:25
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.

1 participant