Skip to content

Potential fix for code scanning alert no. 3: DOM text reinterpreted as HTML#24

Draft
agoudbg wants to merge 1 commit intophpfrom
alert-autofix-3
Draft

Potential fix for code scanning alert no. 3: DOM text reinterpreted as HTML#24
agoudbg wants to merge 1 commit intophpfrom
alert-autofix-3

Conversation

@agoudbg
Copy link
Copy Markdown
Member

@agoudbg agoudbg commented Apr 22, 2026

Potential fix for https://github.com/nm-Team/WebSite/security/code-scanning/3

Use text insertion instead of HTML insertion for user/DOM-influenced strings.

Best fix in this snippet:

  • Replace .html(...) with .text(...) for all .dTip message writes that are plain text.
  • Keep empty-clear behavior by using .text("") instead of .html("").

Specifically in src/js/questionnaire.js, update the .dTip writes at:

  • lines 5, 9, 17, 21, 25, 29, and 57.

No new imports or helper methods are needed. This preserves functionality (showing validation messages) while preventing HTML interpretation/XSS.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates questionnaire validation message rendering to avoid injecting user/DOM-influenced strings as HTML, addressing code scanning alert #3 (DOM text reinterpreted as HTML / potential XSS).

Changes:

  • Replaced .html(...) with .text(...) for .dTip validation message writes.
  • Preserved “clear message” behavior by using .text("") instead of .html("").

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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