Comparing version 0.0.3 to 0.0.4
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). |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
647475
2
13
4932
0
175
1
1
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebuglog@0.0.2(transitive)
+ Addeddicer@0.1.3(transitive)
+ Addedreadable-stream@1.1.7(transitive)
- Removediconv-lite@0.2.10
- Removedabort-controller@3.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removeddicer@0.1.2(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removediconv-lite@0.2.10(transitive)
- Removedieee754@1.2.1(transitive)
- Removedprocess@0.11.10(transitive)
- Removedreadable-stream@4.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
Updateddicer@0.1.3
Updatedreadable-stream@1.1.7