summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorIdan Moral <idan22moral@gmail.com>2021-07-19 00:45:19 (GMT)
committerGitHub <noreply@github.com>2021-07-19 00:45:19 (GMT)
commit35b98e38b6edd63153fc8e092f94cb20725dacc1 (patch)
tree0075d1bd3b9f195c5bd60553f9adcb5ef72a6fa1 /Doc
parentb494685b2548489efcc66993cc6c13b027ce3b26 (diff)
downloadcpython-35b98e38b6edd63153fc8e092f94cb20725dacc1.zip
cpython-35b98e38b6edd63153fc8e092f94cb20725dacc1.tar.gz
cpython-35b98e38b6edd63153fc8e092f94cb20725dacc1.tar.bz2
bpo-43086: Add handling for out-of-spec data in a2b_base64 (GH-24402)
binascii.a2b_base64 gains a strict_mode= parameter. When enabled it will raise an error on input that deviates from the base64 spec in any way. The default remains False for backward compatibility. Code reviews and minor tweaks by: Gregory P. Smith <greg@krypto.org> [Google]
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/binascii.rst14
1 files changed, 13 insertions, 1 deletions
diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst
index 2c0c1bc..fd5df69 100644
--- a/Doc/library/binascii.rst
+++ b/Doc/library/binascii.rst
@@ -50,11 +50,23 @@ The :mod:`binascii` module defines the following functions:
Added the *backtick* parameter.
-.. function:: a2b_base64(string)
+.. function:: a2b_base64(string, strict_mode=False)
Convert a block of base64 data back to binary and return the binary data. More
than one line may be passed at a time.
+ If *strict_mode* is true, only valid base64 data will be converted. Invalid base64
+ data will raise :exc:`binascii.Error`.
+
+ Valid base64:
+ * Conforms to :rfc:`3548`.
+ * Contains only characters from the base64 alphabet.
+ * Contains no excess data after padding (including excess padding, newlines, etc.).
+ * Does not start with a padding.
+
+ .. versionchanged:: 3.11
+ Added the *strict_mode* parameter.
+
.. function:: b2a_base64(data, *, newline=True)