New submission from Vikram Hegde:
Here is the relevant code snippet from decode_generalized_number() in
punycode.py
try:
char = ord(extended[extpos])
except IndexError:
if errors == "strict":
raise UnicodeError("incomplete punicode string")
return extpos + 1, None
extpos += 1
if 0x41 <= char <= 0x5A: # A-Z
digit = char - 0x41
elif 0x30 <= char <= 0x39:
digit = char - 22 # 0x30-26
elif errors == "strict":
raise UnicodeError("Invalid extended code point '%s'"
% extended[extpos])
While raising the UnicodeError() in the last line above, it accesses
extended[extpos]. However extpos was incremented by 1 a few lines above that.
This causes two errors:
1) The UnicodeError() prints the wrong character (the one after the
character we want)
2) If the previous extpos was the last character in the string, then
attempting to print character at extpos+1 will raise an IndexError.
----------
components: Library (Lib)
messages: 295127
nosy: Vikram Hegde
priority: normal
severity: normal
status: open
title: punycode codec raises IndexError in decode_generalized_number()
type: crash
versions: Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30566>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com