Skip to content

Commit

Permalink
fix(imap): Support invalid servers that return a full partial instead…
Browse files Browse the repository at this point in the history
… of starting byte for a FETCH property
  • Loading branch information
andris9 committed Nov 1, 2024
1 parent fca082d commit 7281ce9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module.exports = {
)
.toString()
.toLowerCase()
.replace(/<\d+>$/, '');
.replace(/<\d+(\.\d+)?>$/, '');
continue;
}
if (typeof key !== 'string') {
Expand Down
59 changes: 59 additions & 0 deletions test/imap-parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,3 +1002,62 @@ module.exports['IMAP Parser, subfolder square bracket'] = test =>
{ type: 'ATOM', value: 'INBOX.[Airmail].Snooze' }
]);
});

module.exports['IMAP Parser, FETCH with full range'] = test =>
asyncWrapper(test, async test => {
let parsed = await parser('* 32 FETCH (UID 32 RFC822.SIZE 3991 BODY[2.MIME] "(* 61B literal *)" BODY[2]<0.65536> "(* 6B literal *)")');
console.log(JSON.stringify(parsed.attributes));
test.deepEqual(parsed.attributes, [
{
type: 'ATOM',
value: 'FETCH'
},
[
{
type: 'ATOM',
value: 'UID'
},
{
type: 'ATOM',
value: '32'
},
{
type: 'ATOM',
value: 'RFC822.SIZE'
},
{
type: 'ATOM',
value: '3991'
},
{
type: 'ATOM',
value: 'BODY',
section: [
{
type: 'ATOM',
value: '2.MIME'
}
]
},
{
type: 'STRING',
value: '(* 61B literal *)'
},
{
type: 'ATOM',
value: 'BODY',
section: [
{
type: 'ATOM',
value: '2'
}
],
partial: [0, 65536]
},
{
type: 'STRING',
value: '(* 6B literal *)'
}
]
]);
});

0 comments on commit 7281ce9

Please sign in to comment.