fix header value parsing behavior for folded lines

fork
mscdex 12 years ago
parent 4e0e7436e3
commit baf18ad2b8

@ -1,8 +1,7 @@
var utils = require('./imap.utilities'); var utils = require('./imap.utilities');
var reCRLF = /\r\n/g, var reCRLF = /\r\n/g,
reHdr = /^([^:]+):\s?(.+)?$/, reHdr = /^([^:]+):[ \t]?(.+)?$/;
reHdrFold = /^\s+(.+)$/;
exports.convStr = function(str, literals) { exports.convStr = function(str, literals) {
if (str[0] === '"') if (str[0] === '"')
@ -29,8 +28,9 @@ exports.parseHeaders = function(str) {
continue; continue;
if (lines[i][0] === '\t' || lines[i][0] === ' ') { if (lines[i][0] === '\t' || lines[i][0] === ' ') {
// folded header content // folded header content
m = reHdrFold.exec(lines[i]); // RFC2822 says to just remove the CRLF and not the whitespace following
headers[h][headers[h].length - 1] += m[1]; // it, so we follow the RFC and include the leading whitespace ...
headers[h][headers[h].length - 1] += lines[i];
} else { } else {
m = reHdr.exec(lines[i]); m = reHdr.exec(lines[i]);
h = m[1].toLowerCase(); h = m[1].toLowerCase();

Loading…
Cancel
Save