Skip to content

Support mail box names containing square brackets #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function parseQuotaRoot(text, literals) {
}

function parseBoxList(text, literals) {
var r = parseExpr(text, literals);
var r = parseExpr(text, literals, null, null, false);
return {
flags: r[0],
delimiter: r[1],
Expand Down
58 changes: 58 additions & 0 deletions test/test-parse-mailbox-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
var parseExpr = require('../lib/Parser').parseExpr;

var assert = require('assert'),
inspect = require('util').inspect;

[

{ source: '(\HasNoChildren) "." SimpleName',
expected: [ [ 'HasNoChildren' ], '.', "SimpleName" ],
what: 'Simple mailbox name'
},

{ source: '(\HasNoChildren) "." "SimpleNameQuoted"',
expected: [ [ 'HasNoChildren' ], '.', "SimpleNameQuoted" ],
what: 'Quoted mailbox name'
},

{ source: '(\HasNoChildren) "." "Simple Name Quoted With Spaces"',
expected: [ [ 'HasNoChildren' ], '.', "Simple Name Quoted With Spaces" ],
what: 'Quoted mailbox name with spaces'
},

{ source: '(\HasNoChildren) "." [NameWithBrackets].AndChild',
expected: [ [ 'HasNoChildren' ], '.', [ 'NameWithBrackets' ], '.AndChild' ],
what: 'Mailbox name containings brackets'
},

{ source: '(\HasNoChildren) "." "[Name With Quotes Spaces Brackets.AndChild]"',
expected: [ [ 'HasNoChildren' ], '.', '[Name With Quotes Spaces Brackets.AndChild]' ],
what: 'Mailbox name containings quotes, spaces and brackets'
},



].forEach(function(v) {
var result;

try {
result = parseExpr(v.source, null, null, false);
} catch (e) {
console.log(makeMsg(v.what, 'JS Exception: ' + e.stack));
return;
}

assert.deepEqual(result,
v.expected,
makeMsg(v.what,
'Result mismatch:'
+ '\nParsed: ' + inspect(result, false, 10)
+ '\nExpected: ' + inspect(v.expected, false, 10)
)
);

});

function makeMsg(what, msg) {
return '[' + what + ']: ' + msg;
}