Skip to content

Fix DOM text reinterpreted as HTML in enhanced-textbox#5953

Open
kr8n3r wants to merge 1 commit into
mainfrom
fix-dom-tetx-interpreted-as-html-enhanced-textbox
Open

Fix DOM text reinterpreted as HTML in enhanced-textbox#5953
kr8n3r wants to merge 1 commit into
mainfrom
fix-dom-tetx-interpreted-as-html-enhanced-textbox

Conversation

@kr8n3r
Copy link
Copy Markdown
Contributor

@kr8n3r kr8n3r commented Jun 5, 2026

This is to avoid any potential XSS vectors of attack.

Resolves
https://github.com/alphagov/notifications-admin/security/code-scanning/3
https://github.com/alphagov/notifications-admin/security/code-scanning/4

contentReplaced method was updated to now create a DocumentFragment look through string of characters in the textarea and wrap any placeholders in span depending on their type (regular vs optional). It then returns original text (without placeholders) and placeholder values.

contentEscaped method can be removed as we now apply text that doesn't contain any placeholders directly in the update method.

update method was updated to use .textContent to apply raw text as the browser substitues < and > characters to harmless < and >

For text with placeholders we use .append which works in the same way as .textContent.

This is to avoid any potential XSS vectors of
attack.

`contentReplaced` method was updated to now
create a `DocumentFragment` look through string of
characters in the textarea and wrap any placeholders
in `span` depending on their type (regular vs
optional). It then returns original text (without
placeholders) and placeholder values.

`contentEscaped` method can be removed as we now apply text
that doesn't contain any placeholders directly in
the `update` method.

`update` method was update to use `.textContent`
to apply raw text as the browser substitues
< and > characters to harmless &lt; and &gt;

For text with placeholders we use `.append` which
works in teh same way as `.textContent`.
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