diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-24 10:08:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-24 10:08:11 (GMT) |
commit | 6c783ac15de8b7e54d889e926af7223803c22515 (patch) | |
tree | f64742e3986e7db61e69c964ff363034e650adb6 /Lib/base64.py | |
parent | 510addf63f484da826ad1886c4ed14f6395e4018 (diff) | |
parent | 205e75bb629408d850efd6659c87ba1f8512b44b (diff) | |
download | cpython-6c783ac15de8b7e54d889e926af7223803c22515.zip cpython-6c783ac15de8b7e54d889e926af7223803c22515.tar.gz cpython-6c783ac15de8b7e54d889e926af7223803c22515.tar.bz2 |
Issue #25913: Leading <~ is optional now in base64.a85decode() with adobe=True.
Patch by Swati Jaiswal.
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-x | Lib/base64.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/base64.py b/Lib/base64.py index ab3b1bf..67e54f0 100755 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -366,10 +366,15 @@ def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'): """ b = _bytes_from_decode_data(b) if adobe: - if not (b.startswith(_A85START) and b.endswith(_A85END)): - raise ValueError("Ascii85 encoded byte sequences must be bracketed " - "by {!r} and {!r}".format(_A85START, _A85END)) - b = b[2:-2] # Strip off start/end markers + if not b.endswith(_A85END): + raise ValueError( + "Ascii85 encoded byte sequences must end " + "with {!r}".format(_A85END) + ) + if b.startswith(_A85START): + b = b[2:-2] # Strip off start/end markers + else: + b = b[:-2] # # We have to go through this stepwise, so as to ignore spaces and handle # special short sequences |