Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

content

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content - npm Package Compare versions

Comparing version 4.0.3 to 4.0.4

30

lib/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc