claird / PyPDF4

A utility to read and write PDFs with Python
obsolete-https://pythonhosted.org/PyPDF2/
Other
328 stars 61 forks source link

ASCII85 decoder must throw a ValueError if a 'z' is encountered mid-group #50

Closed kurtmckee closed 5 years ago

kurtmckee commented 5 years ago

Currently the ASCII85 decoder uses an assert to check whether a 'z' character is found at the start of a new group of characters. However, the assert will be ignored if Python is run with optimizations turned on. Instead, it should throw a ValueError if the 'z' is encountered anywhere other than the start of a new group.

This is important because once Python 2 support is dropped the implementation can simply use base64.a85encode(data, adobe=True), so matching this code now will help prepare PyPDF4 to drop Python 2 support.