Parser: decode names in envelope

fork
Brian White 10 years ago
parent d423813130
commit 42a486d2df

@ -588,13 +588,7 @@ function parseStructExtra(part, partLen, cur, next) {
function parseFetchEnvelope(list) {
return {
date: new Date(list[0]),
subject: decodeWords(list[1], {
buffer: undefined,
encoding: undefined,
consecutive: false,
replaces: undefined,
curReplace: undefined
}),
subject: decodeWords(list[1]),
from: parseEnvelopeAddresses(list[2]),
sender: parseEnvelopeAddresses(list[3]),
replyTo: parseEnvelopeAddresses(list[4]),
@ -627,7 +621,7 @@ function parseEnvelopeAddresses(list) {
};
} else { // regular user address
var info = {
name: addr[0],
name: decodeWords(addr[0]),
mailbox: addr[2],
host: addr[3]
};
@ -879,6 +873,18 @@ function qEncReplacer(match, byte) {
}
function decodeWords(str, state) {
var pendoffset = -1;
if (!state) {
state = {
buffer: undefined,
encoding: undefined,
consecutive: false,
replaces: undefined,
curReplace: undefined,
remainder: undefined
};
}
state.replaces = [];
var bytes, m, next, i, j, leni, lenj, seq, replaces = [], lastReplace = {};

@ -21,6 +21,14 @@ var assert = require('assert'),
],
what: 'RFC3501 example #2'
},
{ source: '("=?utf-8?Q?=C2=A9=C2=AEAZ=C2=A5?=" NIL "crazy" "example.org")',
expected: [ { name: '©®AZ¥',
mailbox: 'crazy',
host: 'example.org'
}
],
what: 'Name with encoded word(s)'
},
{ source: '(NIL NIL "imap" NIL)'
+ '(NIL NIL NIL NIL)',
expected: [ { group: 'imap',

Loading…
Cancel
Save