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

nodecaf

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodecaf - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

8

CHANGELOG.md

@@ -8,2 +8,7 @@ # Nodecaf Changelog

## [v0.7.2] - 2019-07-09
### Fixed
- bug when filtering requests with charset on content-type
## [v0.7.1] - 2019-07-08

@@ -158,2 +163,3 @@

[v0.7.0]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.0
[v0.7.1]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.1s
[v0.7.1]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.1
[v0.7.1]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.2

43

lib/route-adapter.js

@@ -16,17 +16,29 @@ const os = require('os');

function parseContentType(req){
try{
var ct = contentType.parse(req);
}
catch(e){
ct = { parameters: {} };
}
req.contentType = ct.type;
req.contentCharset = ct.parameters.charset || 'utf8';
}
function filter(custom, req, res, next){
// this => app
req.hasBody = Boolean(req.headers['content-length']);
if(!req.hasBody)
return next();
let filter = custom || this.accepts || false;
if(filter && !req.headers['content-type'])
return next(errors.BadRequest('Missing \'Content-Type\' header'));
if(!filter || !req.headers['content-length'])
return next();
parseContentType(req);
let ct = req.headers['content-type'];
if(!ct)
return next(errors.BadRequest('Missing \'Content-Type\' header'));
if(filter && !filter.includes(req.contentType))
return next(errors.BadRequest('Unsupported content type \'' + req.contentType + '\''));
if(!filter.includes(ct))
return next(errors.BadRequest('Unsupported content type \'' + ct + '\''));
next();

@@ -37,18 +49,11 @@ }

req.body = '';
if(!req.headers['content-length'])
if(!req.hasBody)
return next();
try{
var ct = contentType.parse(req);
}
catch(e){
ct = { type: 'text/plain', parameters: { charset: 'utf8' } };
}
if(req.contentType in parsers)
return parsers[req.contentType](req, res, next);
if(ct.type in parsers)
return parsers[ct.type](req, res, next);
req.body = await getRawBody(req, {
length: req.headers['content-length'],
encoding: ct.parameters.charset || 'utf8'
encoding: req.contentCharset
});

@@ -55,0 +60,0 @@ next();

{
"name": "nodecaf",
"version": "0.7.1",
"version": "0.7.2",
"description": "Nodecaf is an Express framework for developing REST APIs in a quick and convenient manner.",

@@ -50,8 +50,8 @@ "main": "lib/main.js",

"devDependencies": {
"form-data": "^2.4.0",
"form-data": "^2.5.0",
"muhb": "^0.1.1",
"swagger-parser": "^7.0.1",
"tempper": "^0.1.0",
"swagger-parser": "^8.0.0",
"tempper": "^0.1.1",
"wtfnode": "^0.8.0"
}
}

Sorry, the diff of this file is not supported yet

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