Comparing version 4.0.3 to 4.0.4
@@ -22,5 +22,9 @@ 'use strict'; | ||
// 1: type/subtype 2: "b" 3: b | ||
internals.contentTypeRegex = /^([^\/\s]+\/[^\s;]+)(?:(?:\s*;\s*boundary=(?:"([^"]+)"|([^;"\s]+)))|(?:\s*;[^=]+=(?:(?:"(?:[^"]+)")|(?:[^;"\s]+))))*$/i; | ||
// 1: type/subtype 2: params | ||
internals.contentTypeRegex = /^([^\/\s]+\/[^\s;]+)(.*)?$/; | ||
// 1: "b" 2: b | ||
internals.paramsRegex = /;\s*boundary=(?:"([^"]+)"|([^;"\s]+))/i; | ||
exports.type = function (header) { | ||
@@ -33,11 +37,21 @@ | ||
const mime = match[1].toLowerCase(); | ||
const boundary = match[2] || match[3]; | ||
if (mime.indexOf('multipart/') === 0 && | ||
!boundary) { | ||
const result = { | ||
mime: match[1].toLowerCase() | ||
}; | ||
throw Boom.badRequest('Invalid content-type header: multipart missing boundary'); | ||
if (result.mime.indexOf('multipart/') === 0) { | ||
const params = match[2]; | ||
if (params) { | ||
const param = params.match(internals.paramsRegex); | ||
if (param) { | ||
result.boundary = param[1] || param[2]; | ||
} | ||
} | ||
if (!result.boundary) { | ||
throw Boom.badRequest('Invalid content-type header: multipart missing boundary'); | ||
} | ||
} | ||
return { mime, boundary }; | ||
return result; | ||
}; | ||
@@ -44,0 +58,0 @@ |
{ | ||
"name": "content", | ||
"description": "HTTP Content-* headers parsing", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"repository": "git://github.com/hapijs/content", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8030
86