Skip to content

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

Merged
albert-mueller merged 1 commit into
mainfrom
alert-autofix-3
Aug 6, 2026
Merged

Potential fix for code scanning alert no. 3: DOM text reinterpreted as HTML#4
albert-mueller merged 1 commit into
mainfrom
alert-autofix-3

Conversation

@albert-mueller

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/albert-mueller/albert-mueller.github.io/security/code-scanning/3

General fix: avoid interpreting untrusted text as HTML. Build DOM nodes programmatically and assign untrusted values via textContent and safe DOM APIs (setAttribute, dataset, or direct property assignment), rather than string-building into innerHTML.

Best fix for this code: in others/translate/app.js, update showComparisonView so both translation-option blocks are constructed with createElement, className, textContent, and button.setAttribute('data-translation', ...). This preserves existing behavior and layout while eliminating HTML parsing of tainted strings. Specifically replace the two innerHTML = \...`` regions (original translation and modified translation cards) with explicit node creation and appending.

No new helper methods or imports are required.

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>
Signed-off-by: Albert Müller <p8bpg9zrw7@privaterelay.appleid.com>
@albert-mueller
albert-mueller marked this pull request as ready for review August 6, 2026 00:39
@albert-mueller
albert-mueller merged commit 482217b into main Aug 6, 2026
2 checks passed
@albert-mueller
albert-mueller deleted the alert-autofix-3 branch August 6, 2026 02:20
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