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

busboy

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

busboy - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

1

lib/main.js

@@ -52,2 +52,3 @@ var fs = require('fs'),

cfg.fileHwm = this.opts.fileHwm;
cfg.defCharset = this.opts.defCharset;
this._parser = new type(this, cfg);

@@ -54,0 +55,0 @@ return;

5

lib/types/multipart.js

@@ -1,2 +0,2 @@

// TODO:
// TODO:
// * support 1 nested multipart level

@@ -27,2 +27,3 @@ // (see second multipart example here:

parsedConType = cfg.parsedConType,
defCharset = cfg.defCharset || 'utf8',
fileopts = typeof cfg.fileHwm === 'number'

@@ -102,3 +103,3 @@ ? { highWaterMark: cfg.fileHwm }

if (charset === undefined)
charset = 'iso-8859-1';
charset = defCharset;

@@ -105,0 +106,0 @@ if (header['content-disposition']) {

@@ -32,3 +32,3 @@ var jsencoding = require('../../deps/encoding/encoding'),

if (charset === undefined)
charset = 'ISO-8859-1';
charset = cfg.defCharset || 'utf8';

@@ -35,0 +35,0 @@ this.decoder = new Decoder();

@@ -0,3 +1,14 @@

var jsencoding = require('../deps/encoding/encoding');
var RE_ENCODED = /%([a-fA-F0-9]{2})/g;
function encodedReplacer(match, byte) {
return String.fromCharCode(parseInt(byte, 16));
}
exports.parseParams = function(str) {
var res = [], inval = false, inquote = false, escaping = false, p = 0,
var res = [],
state = 'key',
charset = '',
inquote = false,
escaping = false,
p = 0,
tmp = '';

@@ -17,3 +28,3 @@

inquote = false;
inval = false;
state = 'key';
} else

@@ -26,4 +37,15 @@ inquote = true;

escaping = false;
if (!inval && str[i] === '=') {
inval = true;
if ((state === 'charset' || state === 'lang') && str[i] === "'") {
if (state === 'charset') {
state = 'lang';
charset = tmp.substring(1);
} else
state = 'value';
tmp = '';
continue;
} else if (state === 'key' && (str[i] === '*' || str[i] === '=')) {
if (str[i] === '*')
state = 'charset';
else
state = 'value';
res[p] = [tmp, undefined];

@@ -33,3 +55,13 @@ tmp = '';

} else if (!inquote && str[i] === ';') {
inval = false;
state = 'key';
if (charset) {
if (tmp.length && jsencoding.encodingExists(charset)) {
try {
tmp = jsencoding.TextDecoder(charset)
.decode(new Buffer(tmp.replace(RE_ENCODED, encodedReplacer),
'binary'));
} catch(e) {}
}
charset = '';
}
if (res[p] === undefined)

@@ -48,2 +80,9 @@ res[p] = tmp;

if (tmp.length) {
if (charset && jsencoding.encodingExists(charset)) {
try {
tmp = jsencoding.TextDecoder(charset)
.decode(new Buffer(tmp.replace(RE_ENCODED, encodedReplacer),
'binary'));
} catch(e) {}
}
if (res[p] === undefined)

@@ -73,2 +112,4 @@ res[p] = tmp;

Decoder.prototype.write = function(str) {
// Replace '+' with ' ' before decoding
str = str.replace(RE_PLUS, ' ');
var res = '';

@@ -101,3 +142,3 @@ var i = 0, p = 0, len = str.length;

res += str.substring(p);
return res.replace(RE_PLUS, ' ');
return res;
};

@@ -104,0 +145,0 @@ Decoder.prototype.reset = function() {

{ "name": "busboy",
"version": "0.0.11",
"version": "0.0.12",
"author": "Brian White <mscdex@mscdex.net>",

@@ -4,0 +4,0 @@ "description": "A streaming parser for HTML form data for node.js",

@@ -208,2 +208,4 @@ Description

* **defCharset** - _string_ - Default character set to use when one isn't defined (Default: 'utf8').
* **limits** - _object_ - Various limits on incoming data. Valid properties are:

@@ -210,0 +212,0 @@

@@ -50,4 +50,4 @@ var UrlEncoded = require('../lib/types/urlencoded'),

},
{ source: ['foo=bar+baz'],
expected: [['foo', 'bar baz', false, false]],
{ source: ['foo=bar+baz%2Bquux'],
expected: [['foo', 'bar baz+quux', false, false]],
what: 'Assigned value with (plus) space'

@@ -136,4 +136,4 @@ },

var cfg = {
limits: v.limits,
headers: null,
limits: v.limits,
headers: null,
parsedConType: parsedConType

@@ -168,2 +168,2 @@ };

return '[' + group + what + ']: ' + msg;
}
}

@@ -49,2 +49,10 @@ var Decoder = require('../lib/utils').Decoder;

},
{ source: ['5%2B5%3D10'],
expected: '5+5=10',
what: 'Encoded plus'
},
{ source: ['5+%2B+5+%3D+10'],
expected: '5 + 5 = 10',
what: 'Spaces and encoded plus'
},
].forEach(function(v) {

@@ -55,4 +63,6 @@ var dec = new Decoder(), result = '';

});
var msg = '[' + group + v.what + ']: decoded string mismatch';
var msg = '[' + group + v.what + ']: decoded string mismatch.\n'
+ 'Saw: ' + result + '\n'
+ 'Expected: ' + v.expected;
assert.deepEqual(result, v.expected, msg);
});

@@ -25,2 +25,26 @@ var parseParams = require('../lib/utils').parseParams;

},
{ source: "text/plain; filename*=iso-8859-1'en'%A3%20rates",
expected: ['text/plain', ['filename', '£ rates']],
what: 'Extended parameter (RFC 5987) with language'
},
{ source: "text/plain; filename*=utf-8''%c2%a3%20and%20%e2%82%ac%20rates",
expected: ['text/plain', ['filename', '£ and € rates']],
what: 'Extended parameter (RFC 5987) without language'
},
{ source: "text/plain; filename*=utf-8''%E6%B5%8B%E8%AF%95%E6%96%87%E6%A1%A3",
expected: ['text/plain', ['filename', '测试文档']],
what: 'Extended parameter (RFC 5987) without language #2'
},
{ source: "text/plain; filename*=iso-8859-1'en'%A3%20rates; altfilename*=utf-8''%c2%a3%20and%20%e2%82%ac%20rates",
expected: ['text/plain', ['filename', '£ rates'], ['altfilename', '£ and € rates']],
what: 'Multiple extended parameters (RFC 5987) with mixed charsets'
},
{ source: "text/plain; filename*=iso-8859-1'en'%A3%20rates; altfilename=\"foobarbaz\"",
expected: ['text/plain', ['filename', '£ rates'], ['altfilename', 'foobarbaz']],
what: 'Mixed regular and extended parameters (RFC 5987)'
},
{ source: "text/plain; filename=\"foobarbaz\"; altfilename*=iso-8859-1'en'%A3%20rates",
expected: ['text/plain', ['filename', 'foobarbaz'], ['altfilename', '£ rates']],
what: 'Mixed regular and extended parameters (RFC 5987) #2'
},
].forEach(function(v) {

@@ -27,0 +51,0 @@ var result = parseParams(v.source),

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