Skip to content

Commit

Permalink
Merge branch 'release/0.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelspiss committed Mar 31, 2019
2 parents 2fc3517 + 893574a commit 5c92b21
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2

- Merge #10, fix string with leading escaped character

## 0.2.1

- Fix #4, bug that prevented mailboxes with spaces from being opened
Expand Down
9 changes: 3 additions & 6 deletions lib/src/imap_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,16 @@ class ImapBuffer {
List<int> charCodes = <int>[];
int nextChar = await _getCharCode(proceed: true);
while (nextChar != 34 /* " */) {
charCodes.add(nextChar);
nextChar = await _getCharCode(proceed: true);
if (nextChar == 92 /* \ */) {
nextChar = await _getCharCode(proceed: true); // skip first backslash
if (nextChar == 92 /* \ */ || nextChar == 34 /* " */) {
charCodes.add(nextChar);
nextChar = await _getCharCode(proceed: true); // skip first backslash
} else {
if (nextChar != 34 /* " */ && nextChar != 92 /* \ */) {
// bad format, only escaped backslash or quotation mark are supported
throw new SyntaxErrorException(
"Unknown escape sequence \\${String.fromCharCode(nextChar)}");
}
}
charCodes.add(nextChar);
nextChar = await _getCharCode(proceed: true);
}
if (autoReleaseBuffer) _releaseUsedBuffer();
return new ImapWord(ImapWordType.string, String.fromCharCodes(charCodes));
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: imap_client
description: An interface to get emails via the imap protocol (version 4rev1)
version: 0.2.1
version: 0.2.2
homepage: https://github.com/michaelspiss/imap_client
author: Michael Spiss <michaelspiss.dev@mailbox.org>
documentation:

environment:
sdk: '>=2.0.0-dev.63.0 <3.0.0'
sdk: '>=2.0.0 <3.0.0'

dependencies:
logging: ^0.11.3
Expand Down
5 changes: 5 additions & 0 deletions test/imap_buffer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ void main() {
_controller.add(list);
expect((await _buffer.readQuotedString()).value, r'A \ backslash \');
});
test('String may start with escaped character', () async {
var list = r'"\"A quoted text\""'.codeUnits;
_controller.add(list);
expect((await _buffer.readQuotedString()).value, '"A quoted text"');
});
test('Throws SyntaxErrorException if a characeter besides ", \\ is escaped',
() async {
var list = r'"A bad \format"'.codeUnits;
Expand Down

0 comments on commit 5c92b21

Please sign in to comment.