Parser: add 'hack' to properly take care of non-literal BODY[*]

fork
mscdex 12 years ago
parent f935a722f1
commit e2c7cdd32f

@ -579,7 +579,7 @@ function parseEnvelopeAddresses(list) {
function parseExpr(o, literals, result, start, useBrackets) {
start = start || 0;
var inQuote = false, lastPos = start - 1, isTop = false, val;
var inQuote = false, lastPos = start - 1, isTop = false, val, isBody = false;
if (useBrackets === undefined)
useBrackets = true;
@ -591,7 +591,14 @@ function parseExpr(o, literals, result, start, useBrackets) {
}
for (var i = start, len = o.str.length; i < len; ++i) {
if (!inQuote) {
if (o.str[i] === '"')
if (isBody) {
if (o.str[i] === ']') {
val = convStr(o.str.substring(lastPos + 1, i + 1), literals);
result.push(val);
lastPos = i;
isBody = false;
}
} else if (o.str[i] === '"')
inQuote = true;
else if (o.str[i] === ' ' || o.str[i] === ')'
|| (useBrackets && o.str[i] === ']')) {
@ -603,10 +610,17 @@ function parseExpr(o, literals, result, start, useBrackets) {
return i;
lastPos = i;
} else if ((o.str[i] === '(' || (useBrackets && o.str[i] === '['))) {
var innerResult = [];
i = parseExpr(o, literals, innerResult, i + 1, useBrackets);
lastPos = i;
result.push(innerResult);
if (o.str[i] === '['
&& i - 4 >= start
&& o.str.substring(i - 4, i).toUpperCase() === 'BODY') {
isBody = true;
lastPos = i - 5;
} else {
var innerResult = [];
i = parseExpr(o, literals, innerResult, i + 1, useBrackets);
lastPos = i;
result.push(innerResult);
}
}
} else if (o.str[i] === '"' &&
(o.str[i - 1] &&

Loading…
Cancel
Save