Skip to content

Potential fix for code scanning alert no. 19: DOM text reinterpreted as HTML - #32

Merged
digreatbrian merged 1 commit into
mainfrom
alert-autofix-19
Jul 3, 2026
Merged

Potential fix for code scanning alert no. 19: DOM text reinterpreted as HTML#32
digreatbrian merged 1 commit into
mainfrom
alert-autofix-19

Conversation

@digreatbrian

Copy link
Copy Markdown
Member

Potential fix for https://github.com/duckframework/duck/security/code-scanning/19

Use HTML escaping for all traceback text segments before building the highlighted markup, so only the intentionally added <span> wrappers are interpreted as HTML.

Best fix in duck/etc/templates/base.html (in the <script> block around lines 850–877):

  1. Add a small local helper, e.g. escapeHtml(str), that escapes &, <, >, ", '.
  2. In colourTraceback(), escape each line first (const safeLine = escapeHtml(line)).
  3. Run regex tests on the original line (to preserve matching behavior), but build returned HTML using safeLine.
  4. For the file/line replacement branch, apply .replace(...) to safeLine so captured groups are escaped text, then wrapped in spans.
  5. Keep pre.innerHTML = html.join('\n'); unchanged, since content is now safely encoded except for controlled span tags.

No new imports or dependencies are required.

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

…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@digreatbrian
digreatbrian marked this pull request as ready for review July 3, 2026 10:41
@digreatbrian
digreatbrian merged commit b283491 into main Jul 3, 2026
6 checks passed
@digreatbrian
digreatbrian deleted the alert-autofix-19 branch July 3, 2026 10:41
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