Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.0.4] - 2026-01-05

### Fixed
- Fix handling escaping arrays in trusted html

## [v1.0.3] - 2026-01-05

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aegisjsproject/escape",
"version": "1.0.3",
"version": "1.0.4",
"description": "String escaping utilities for HTML and DOM attributes.",
"keywords": [
"security",
Expand Down
8 changes: 7 additions & 1 deletion trusted-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export function html(strings, ...values) {
? strings.map(input => isTrustedHTML(input) ? input : escapeHTML(input)).join('')
: escapeHTML(strings));
} else {
return policy.createHTML(String.raw(strings, ...values.map(val => isTrustedHTML(val) ? val : escapeHTML(val))));
return policy.createHTML(String.raw(
strings,
...values.map(val => Array.isArray(val)
? val.flatMap(v => isTrustedHTML(v) ? v : escapeHTML(v)).join('')
: isTrustedHTML(val) ? val : escapeHTML(val)
)
));
}
}
2 changes: 1 addition & 1 deletion trusted-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Trusted HTML Policy (Node/Fallback Mode)', () => {
const items = ['<br>', '<b>bold</b>'];
const result = html`Items: ${items}`;

assert.strictEqual(result.toString(), 'Items: &lt;br&gt;,&lt;b&gt;bold&lt;/b&gt;');
assert.strictEqual(result.toString(), 'Items: &lt;br&gt;&lt;b&gt;bold&lt;/b&gt;');
});

test('Security: enforces Double Escaping in fallback mode', () => {
Expand Down
Loading