@adobe/helix-html-pipeline 3.7.5 → 3.7.6
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.7.6](https://github.com/adobe/helix-html-pipeline/compare/v3.7.5...v3.7.6) (2022-11-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improve custom header handling ([#205](https://github.com/adobe/helix-html-pipeline/issues/205)) ([3867fef](https://github.com/adobe/helix-html-pipeline/commit/3867fef601735ed8dc6921c0391bd0de148f0245)), closes [#204](https://github.com/adobe/helix-html-pipeline/issues/204) [#202](https://github.com/adobe/helix-html-pipeline/issues/202) [#199](https://github.com/adobe/helix-html-pipeline/issues/199)
|
|
7
|
+
|
|
1
8
|
## [3.7.5](https://github.com/adobe/helix-html-pipeline/compare/v3.7.4...v3.7.5) (2022-11-18)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.6",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"hast-util-to-html": "8.0.3",
|
|
51
51
|
"hast-util-to-string": "2.0.0",
|
|
52
52
|
"hastscript": "7.1.0",
|
|
53
|
-
"jose": "4.11.
|
|
53
|
+
"jose": "4.11.1",
|
|
54
54
|
"mdast-util-gfm-footnote": "1.0.1",
|
|
55
55
|
"mdast-util-gfm-strikethrough": "1.0.2",
|
|
56
56
|
"mdast-util-gfm-table": "1.0.6",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"@semantic-release/git": "10.0.1",
|
|
84
84
|
"@semantic-release/npm": "9.0.1",
|
|
85
85
|
"c8": "7.12.0",
|
|
86
|
-
"eslint": "8.
|
|
86
|
+
"eslint": "8.28.0",
|
|
87
87
|
"eslint-import-resolver-exports": "1.0.0-beta.3",
|
|
88
88
|
"eslint-plugin-header": "3.1.1",
|
|
89
89
|
"eslint-plugin-import": "2.26.0",
|
|
90
|
-
"esmock": "2.0.
|
|
90
|
+
"esmock": "2.0.9",
|
|
91
91
|
"husky": "8.0.2",
|
|
92
92
|
"js-yaml": "4.1.0",
|
|
93
|
-
"jsdom": "20.0.
|
|
93
|
+
"jsdom": "20.0.3",
|
|
94
94
|
"junit-report-builder": "3.0.1",
|
|
95
|
-
"lint-staged": "13.0.
|
|
95
|
+
"lint-staged": "13.0.4",
|
|
96
96
|
"mocha": "10.1.0",
|
|
97
97
|
"mocha-multi-reporters": "1.5.1",
|
|
98
98
|
"remark-gfm": "3.0.1",
|
|
@@ -9,7 +9,43 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
function cleanupHeaderValue(value) {
|
|
13
|
+
return value
|
|
14
|
+
.replace(/[^\t\u0020-\u007E\u0080-\u00FF]/g, '')
|
|
15
|
+
.substring(0, 1024 * 64);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Computes the access-control-allow-origin header value.
|
|
20
|
+
* The value can either be a single value or a comma separated list of origin names or patterns.
|
|
21
|
+
* If only a single static value is given (eg `*` or `https://www.adobe.com`), it is used verbatim.
|
|
22
|
+
* If multiple values are given, the one matching the origin request header is used.
|
|
23
|
+
* If any of the values is a regexp, the origin request header is used, if any match is given.
|
|
24
|
+
*
|
|
25
|
+
* @param {PipelineRequest} req
|
|
26
|
+
* @param {string} value
|
|
27
|
+
* @return {string} the access-control-allow-origin header value.
|
|
28
|
+
*/
|
|
29
|
+
function getACAOriginValue(req, value) {
|
|
30
|
+
/** @type string */
|
|
31
|
+
const origin = req.headers.get('origin') || '*';
|
|
32
|
+
const values = value.split(',')
|
|
33
|
+
.map((v) => v.trim());
|
|
34
|
+
|
|
35
|
+
if (values.length === 1 && !values[0].startsWith('/')) {
|
|
36
|
+
return values[0];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const v of values) {
|
|
40
|
+
if (v.startsWith('/') && v.endsWith('/') && new RegExp(v.substring(1, v.length - 1)).test(origin)) {
|
|
41
|
+
return origin;
|
|
42
|
+
}
|
|
43
|
+
if (v === origin) {
|
|
44
|
+
return origin;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
13
49
|
|
|
14
50
|
/**
|
|
15
51
|
* Decorates the pipeline response object with the headers defined in metadata.json.
|
|
@@ -23,7 +59,13 @@ export default function setCustomResponseHeaders(state, req, res) {
|
|
|
23
59
|
Object.entries(state.headers.getModifiers(state.info.path)).forEach(([name, value]) => {
|
|
24
60
|
// only use `link` header for extensionless pipeline
|
|
25
61
|
if (name !== 'link' || (state.type === 'html' && state.info.selector === '')) {
|
|
26
|
-
|
|
62
|
+
let val = cleanupHeaderValue(value);
|
|
63
|
+
if (name === 'access-control-allow-origin') {
|
|
64
|
+
val = getACAOriginValue(req, val);
|
|
65
|
+
}
|
|
66
|
+
if (val) {
|
|
67
|
+
res.headers.set(name, val);
|
|
68
|
+
}
|
|
27
69
|
}
|
|
28
70
|
});
|
|
29
71
|
}
|