@adobe/helix-html-pipeline 6.24.1 → 6.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/steps/csp.js +35 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [6.24.3](https://github.com/adobe/helix-html-pipeline/compare/v6.24.2...v6.24.3) (2025-04-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency mime to v4.0.7 ([#851](https://github.com/adobe/helix-html-pipeline/issues/851)) ([e117c04](https://github.com/adobe/helix-html-pipeline/commit/e117c0463b132b10f8754a04acd06da5b613443b))
|
|
7
|
+
|
|
8
|
+
## [6.24.2](https://github.com/adobe/helix-html-pipeline/compare/v6.24.1...v6.24.2) (2025-04-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Add script nonce to <link as=script> ([#850](https://github.com/adobe/helix-html-pipeline/issues/850)) ([182f281](https://github.com/adobe/helix-html-pipeline/commit/182f2816c018ed4e68af44ff3738ca9722984455))
|
|
14
|
+
|
|
1
15
|
## [6.24.1](https://github.com/adobe/helix-html-pipeline/compare/v6.24.0...v6.24.1) (2025-03-28)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "6.24.
|
|
3
|
+
"version": "6.24.3",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"lodash.escape": "4.0.1",
|
|
56
56
|
"mdast-util-to-hast": "13.2.0",
|
|
57
57
|
"mdast-util-to-string": "4.0.0",
|
|
58
|
-
"mime": "4.0.
|
|
58
|
+
"mime": "4.0.7",
|
|
59
59
|
"parse5": "7.2.1",
|
|
60
60
|
"rehype-format": "5.0.1",
|
|
61
61
|
"rehype-parse": "9.0.1",
|
package/src/steps/csp.js
CHANGED
|
@@ -111,9 +111,15 @@ function createAndApplyNonceOnAST(res, tree, metaCSP, headerCSP, headerCSPRO) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
visit(tree, (node) => {
|
|
114
|
-
if (scriptNonce
|
|
115
|
-
node.properties
|
|
116
|
-
|
|
114
|
+
if (scriptNonce) {
|
|
115
|
+
if (node.tagName === 'script' && node.properties?.nonce === 'aem') {
|
|
116
|
+
node.properties.nonce = nonce;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (node.tagName === 'link' && node.properties?.as === 'script' && node.properties?.nonce === 'aem') {
|
|
120
|
+
node.properties.nonce = nonce;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
if (styleNonce
|
|
@@ -222,14 +228,34 @@ export function contentSecurityPolicyOnCode(state, res) {
|
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
if (scriptNonce
|
|
226
|
-
|
|
227
|
-
|
|
231
|
+
if (scriptNonce) {
|
|
232
|
+
if (tag.tagName === 'script' && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
|
|
233
|
+
chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (tag.tagName === 'link'
|
|
238
|
+
&& tag.attrs.find((attr) => attr.name === 'as' && attr.value === 'script')
|
|
239
|
+
&& tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')
|
|
240
|
+
) {
|
|
241
|
+
chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
228
244
|
}
|
|
229
245
|
|
|
230
|
-
if (styleNonce
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
if (styleNonce) {
|
|
247
|
+
if (tag.tagName === 'style' && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
|
|
248
|
+
chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (tag.tagName === 'link'
|
|
253
|
+
&& tag.attrs.find((attr) => attr.name === 'rel' && attr.value === 'stylesheet')
|
|
254
|
+
&& tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')
|
|
255
|
+
) {
|
|
256
|
+
chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
233
259
|
}
|
|
234
260
|
|
|
235
261
|
chunks.push(getRawHTML(tag));
|