-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-22602: Raise an exception in the UTF-7 decoder for ill-formed sequences starting with "+" #8741
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1630,6 +1630,10 @@ def test_codecs_utf7(self): | |
for c in set_o: | ||
self.assertEqual(c.encode('ascii').decode('utf7'), c) | ||
|
||
with self.assertRaisesRegex(UnicodeDecodeError, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add also a test for the non-strict error handler, e.g. "replace". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comment. I've added the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then all correct. |
||
'ill-formed sequence'): | ||
b'+@'.decode('utf-7') | ||
|
||
def test_codecs_utf8(self): | ||
self.assertEqual(''.encode('utf-8'), b'') | ||
self.assertEqual('\u20ac'.encode('utf-8'), b'\xe2\x82\xac') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The UTF-7 decoder now raises :exc:`UnicodeDecodeError` for ill-formed | ||
sequences starting with "+" (as specified in RFC 2152). Patch by Zackery | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
Spytz. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will fail. Is that you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The
self.assertRaises()
on line 1027 checks that a UnicodeDecodeError is raised with the "strict" error handler. Or did you mean something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I put the comment in the wrong line. I think that the test will fail on line 1029
self.assertEqual(raw.decode('utf-7', 'replace'), expected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you're mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add also tests for
b'a+'
andb'a+@'
. It may be need to change the code for proper handling these cases.