Comparing version 4.3.1 to 4.4.0
@@ -5,3 +5,4 @@ /*global unescape*/ | ||
iconvLite = require('iconv-lite'), | ||
quotedPrintable = require('quoted-printable'); | ||
quotedPrintable = require('quoted-printable'), | ||
decodeChunkedTransferEncoding = require('./decodeChunkedTransferEncoding'); | ||
@@ -43,2 +44,3 @@ function quoteRegExp(str) { | ||
Message.prototype.populateFromBuffer = function (buffer) { | ||
this.rawSrc = buffer; | ||
// Hack: Interpret non-ASCII in headers as iso-8859-1: | ||
@@ -66,2 +68,3 @@ var str = ''; | ||
Message.prototype.populateFromString = function (str) { | ||
this.rawSrc = str; | ||
var bodyStartIndex = this.headers.populateFromStringAndReturnBodyStartIndex(str); | ||
@@ -160,2 +163,8 @@ if (bodyStartIndex < str.length) { | ||
if (decodedBody) { | ||
var transferEncoding = this.headers.get('Transfer-Encoding'); | ||
if (transferEncoding && transferEncoding === 'chunked') { | ||
try { | ||
decodedBody = decodeChunkedTransferEncoding(decodedBody); | ||
} catch (e) {} | ||
} | ||
var contentTransferEncoding = this.headers.get('Content-Transfer-Encoding'), | ||
@@ -162,0 +171,0 @@ contentTransferEncodingIsHonored = !contentTransferEncoding; |
{ | ||
"name": "messy", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"description": "Object model for HTTP and RFC822 messages", | ||
@@ -32,3 +32,3 @@ "main": "lib/index.js", | ||
"mocha": "=1.21.4", | ||
"unexpected": "5.0.0-beta31" | ||
"unexpected": "6.3.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
@@ -381,4 +381,51 @@ /*global describe, it*/ | ||
}); | ||
it('should decode Transfer-Encoding:chunked when the body is provided as a string', function () { | ||
expect(new Message( | ||
'Content-Type: text/plain; charset=UTF-8\r\n' + | ||
'Transfer-Encoding: chunked\r\n' + | ||
'\r\n' + | ||
'4\r\n' + | ||
'Wiki\r\n' + | ||
'5\r\n' + | ||
'pedia\r\n' + | ||
'e\r\n' + | ||
' in\r\n\r\nchunks.\r\n' + | ||
'0\r\n' + | ||
'\r\n' | ||
).decodedBody, 'to equal', 'Wikipedia in\r\n\r\nchunks.'); | ||
}); | ||
it('should decode Transfer-Encoding:chunked when the body is provided as a Buffer', function () { | ||
expect(new Message( | ||
new Buffer( | ||
'Content-Type: text/plain; charset=UTF-8\r\n' + | ||
'Transfer-Encoding: chunked\r\n' + | ||
'\r\n' + | ||
'4\r\n' + | ||
'Wiki\r\n' + | ||
'5\r\n' + | ||
'pedia\r\n' + | ||
'e\r\n' + | ||
' in\r\n\r\nchunks.\r\n' + | ||
'0\r\n' + | ||
'\r\n', | ||
'utf-8' | ||
) | ||
).decodedBody, 'to equal', 'Wikipedia in\r\n\r\nchunks.'); | ||
}); | ||
}); | ||
describe('#rawSrc', function () { | ||
it('should be populated when instiating a Message from a string', function () { | ||
var rawSrc = 'Foo: bar\r\n\r\nquux'; | ||
expect(new Message(rawSrc).rawSrc, 'to equal', rawSrc); | ||
}); | ||
it('should be populated when instiating a Message from a Buffer', function () { | ||
var rawSrc = new Buffer('Foo: bar\r\n\r\nquux', 'utf-8'); | ||
expect(new Message(rawSrc).rawSrc, 'to equal', rawSrc); | ||
}); | ||
}); | ||
describe('#fileName', function () { | ||
@@ -385,0 +432,0 @@ describe('when invoked as a getter', function () { |
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
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
118406
31
2451