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.3 to 0.0.4

deps/encoding/encoding-indexes.js

10

lib/main.js
var fs = require('fs'),
WritableStream = require('readable-stream').Writable,
inherits = require('util').inherits,
EventEmitter = require('events').EventEmitter;
WritableStream = require('stream').Writable
|| require('readable-stream').Writable,
inherits = require('util').inherits;

@@ -19,7 +19,7 @@ var utils = require('./utils');

if (opts.headers && opts.headers['content-type'] !== undefined)
if (opts.headers && typeof opts.headers['content-type'] === 'string')
this.parseHeaders(opts.headers);
this.limits = opts.limits;
this.once('finish', function() {
self._parser.end();
self._parser && self._parser.end();
});

@@ -26,0 +26,0 @@ }

@@ -10,4 +10,4 @@ // TODO:

Dicer = require('dicer'),
iconv = require('iconv-lite'),
inherits = require('util').inherits;
inherits = require('util').inherits,
jsencoding = require('../../deps/encoding/encoding');

@@ -46,3 +46,6 @@ var utils = require('../utils');

this.parser = new Dicer({ boundary: boundary });
this.parser = new Dicer({
boundary: boundary,
maxHeaderPairs: (limits && limits.headerPairs)
});
this.parser.on('part', function(part) {

@@ -54,4 +57,3 @@ if (++nparts > partsLimit) {

part.once('header', function(header) {
var contype, fieldname, parsed, charset, encoding,
filename, nsize = 0;
var contype, fieldname, parsed, charset, encoding, filename, nsize = 0;

@@ -69,9 +71,3 @@ if (header['content-type']) {

if (charset === undefined)
charset = 'ISO-8859-1';
else if (charset === 'us-ascii')
charset = 'ascii';
else if (charset === 'utf-8')
charset = 'utf8';
else if (charset === 'utf-16le')
charset = 'ucs2';
charset = 'iso-8859-1';

@@ -136,3 +132,8 @@ if (header['content-disposition']) {

onEnd = function() {
buffer = iconv.decode(new Buffer(buffer, 'binary'), charset);
if (buffer.length && jsencoding.encodingExists(charset)) {
try {
buffer = jsencoding.TextDecoder(charset)
.decode(new Buffer(buffer, 'binary'));
} catch(e) {}
}
boy.emit('field', fieldname, buffer, truncated);

@@ -139,0 +140,0 @@ };

@@ -1,8 +0,7 @@

var iconv = require('iconv-lite');
var jsencoding = require('../../deps/encoding/encoding'),
Decoder = require('../utils').Decoder;
var Decoder = require('../utils').Decoder;
var RE_CHARSET = /^charset$/i;
UrlEncoded.detect = /^application\/x-www-form-urlencoded$/i;
UrlEncoded.detect = /^application\/x-www-form-urlencoded/i;
function UrlEncoded(boy, limits, headers, parsedConType) {

@@ -31,8 +30,2 @@ this.boy = boy;

charset = 'ISO-8859-1';
else if (charset === 'us-ascii')
charset = 'ascii';
else if (charset === 'utf-8')
charset = 'utf8';
else if (charset === 'utf-16le')
charset = 'ucs2';

@@ -57,3 +50,3 @@ this.decoder = new Decoder();

var strconv, idxeq, idxamp, i, p = 0, len = data.length;
var idxeq, idxamp, i, p = 0, len = data.length;

@@ -111,5 +104,3 @@ while (p < len) {

if (key.length) {
this.boy.emit('field', iconv.decode(
new Buffer(key, 'binary'),
this.charset),
this.boy.emit('field', convertVal(buffer, this.charset),
undefined,

@@ -163,10 +154,4 @@ false,

}
this.boy.emit('field', iconv.decode(
new Buffer(this._key, 'binary'),
this.charset),
(this._val
? iconv.decode(
new Buffer(this._val, 'binary'),
this.charset)
: this._val),
this.boy.emit('field', convertVal(this._key, this.charset),
convertVal(this._val, this.charset),
this._valTrunc,

@@ -216,5 +201,3 @@ this._keyTrunc);

if (this._state === 'key' && this._key.length > 0) {
this.boy.emit('field', iconv.decode(
new Buffer(this._key, 'binary'),
this.charset),
this.boy.emit('field', convertVal(this._key, this.charset),
undefined,

@@ -224,10 +207,4 @@ false,

} else if (this._state === 'val') {
this.boy.emit('field', iconv.decode(
new Buffer(this._key, 'binary'),
this.charset),
(this._val
? iconv.decode(
new Buffer(this._val, 'binary'),
this.charset)
: this._val),
this.boy.emit('field', convertVal(this._key, this.charset),
convertVal(this._val, this.charset),
this._valTrunc,

@@ -239,2 +216,13 @@ this._keyTrunc);

function convertVal(val, charset) {
var ret = val;
if (val && val.length && jsencoding.encodingExists(charset)) {
try {
ret = jsencoding.TextDecoder(charset)
.decode(new Buffer(val, 'binary'));
} catch(e) {}
}
return ret;
}
module.exports = UrlEncoded;
{ "name": "busboy",
"version": "0.0.3",
"version": "0.0.4",
"author": "Brian White <mscdex@mscdex.net>",
"description": "A node.js module for parsing incoming HTML form data",
"description": "A streaming parser for HTML form data for node.js",
"main": "./lib/main",
"dependencies": {
"dicer": "0.1.2",
"readable-stream": "*",
"iconv-lite": "0.2.10"
"dicer": "0.1.3",
"readable-stream": "1.1.7"
},

@@ -11,0 +10,0 @@ "scripts": {

@@ -173,1 +173,3 @@

* **parts** - _integer_ - For multipart forms, the max number of parts (fields + files) (Default: Infinity).
* **headerPairs** - _integer_ - For multipart forms, the max number of header key=>value pairs to parse **Default:** 2000 (same as node's http).
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