Skip to content

Commit d6032dd

Browse files
committed
Fix the content-type http header validation for binary format, in commons.js and unmarshaller
Signed-off-by: Fabio José <[email protected]>
1 parent 8ab8bf8 commit d6032dd

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/bindings/http/commons.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
const Constants = require("./constants.js");
2+
3+
function sanityContentType(contentType) {
4+
if(contentType) {
5+
return Array.of(contentType)
6+
.map(c => c.split(";"))
7+
.map(c => c.shift())
8+
.shift();
9+
}
10+
11+
return contentType;
12+
}
13+
114
function sanityAndClone(headers) {
215

316
var sanityHeaders = {};
@@ -8,9 +21,13 @@ function sanityAndClone(headers) {
821
sanityHeaders[header.toLowerCase()] = headers[header];
922
});
1023

24+
sanityHeaders[Constants.HEADER_CONTENT_TYPE] =
25+
sanityContentType(sanityHeaders[Constants.HEADER_CONTENT_TYPE]);
26+
1127
return sanityHeaders;
1228
}
1329

1430
module.exports = {
15-
sanityAndClone
31+
sanityAndClone,
32+
sanityContentType
1633
};

lib/bindings/http/unmarshaller_0_2.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ function validateArgs(payload, headers) {
3232
function resolveBindingName(payload, headers) {
3333

3434
var contentType =
35-
Array.of(headers[Constants.HEADER_CONTENT_TYPE])
36-
.map(c => c.split(";"))
37-
.map(c => c.shift())
38-
.shift();
35+
Commons.sanityContentType(headers[Constants.HEADER_CONTENT_TYPE]);
3936

4037
if(contentType.startsWith(Constants.MIME_CE)){
4138
// Structured

0 commit comments

Comments
 (0)