Changeset 142:f5a6a5297de1
- Timestamp:
- 29/04/10 14:01:30 (22 months ago)
- Author:
- Menno Smits <menno@…>
- Branch:
- default
- Message:
-
Correctly handle \" in quoted strings.
(As reported in comments of #28)
It turns out these were being handled twice causing them to be
incorrectly removed if a string started with a double quote.
Extended tests to cover more cases around escaped double quotes. Prior
to this the test weren't covering enough cases.
- Location:
- imapclient
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r126
|
r142
|
|
| 208 | 208 | literal_len, len(literal_text))) |
| 209 | 209 | return literal_text |
| 210 | | elif token.startswith('"'): |
| 211 | | return token[1:-1] |
| 212 | 210 | elif token.isdigit(): |
| 213 | 211 | return int(token) |
-
|
r135
|
r142
|
|
| 92 | 92 | r'(\HasNoChildren) "/" "Left\"Right"', |
| 93 | 93 | r'(\HasNoChildren) "/" "Left\\Right"', |
| | 94 | r'(\HasNoChildren) "/" "\"Left Right\""', |
| | 95 | r'(\HasNoChildren) "/" "\"Left\\Right\""', |
| 94 | 96 | ]) |
| 95 | 97 | self.assertEqual(folders, [(['\\HasNoChildren'], '/', 'Test "Folder"'), |
| 96 | 98 | (['\\HasNoChildren'], '/', 'Left\"Right'), |
| 97 | | (['\\HasNoChildren'], '/', r'Left\Right')]) |
| | 99 | (['\\HasNoChildren'], '/', r'Left\Right'), |
| | 100 | (['\\HasNoChildren'], '/', r'"Left Right"'), |
| | 101 | (['\\HasNoChildren'], '/', r'"Left\Right"'), |
| | 102 | ]) |
| 98 | 103 | |
| 99 | 104 | def test_empty_response(self): |
-
|
r120
|
r142
|
|
| 133 | 133 | |
| 134 | 134 | def test_quoted_specials(self): |
| | 135 | self._test(r'"\"foo bar\""', '"foo bar"') |
| 135 | 136 | self._test(r'"foo \"bar\""', 'foo "bar"') |
| 136 | 137 | self._test(r'"foo\\bar"', r'foo\bar') |
| … |
… |
|
| 157 | 158 | to_parse = [to_parse] |
| 158 | 159 | output = parse_response(to_parse) |
| 159 | | self.assert_( |
| 160 | | output == expected, |
| 161 | | format_error(to_parse, output, expected), |
| 162 | | ) |
| | 160 | self.assert_(output == expected, |
| | 161 | format_error(to_parse, output, expected)) |
| 163 | 162 | |
| 164 | 163 | def _test_parse_error(self, to_parse, expected_msg): |