werkzeug.http.parse_authorization_header() docstring states:
The return value is either None if the header was invalid or not given
But in case of passing string improperly formatted (i.e. not properly UTF-8 encoded) it raises UnicodeDecodeError exception:
>>> import base64
>>> from werkzeug.http import parse_authorization_header
>>> value = 'Basic ' + base64.b64encode(b'\xffser:pass').decode()
>>> parse_authorization_header(value)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/py3.8/lib/python3.8/site-packages/werkzeug/http.py", line 610, in parse_authorization_header
"username": to_unicode(username, _basic_auth_charset),
File "/py3.8/lib/python3.8/site-packages/werkzeug/_compat.py", line 219, in to_unicode
return x.decode(charset, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Am I right that exception handling should be added in parse_authorization_header()?
werkzeug.http.parse_authorization_header()docstring states:But in case of passing string improperly formatted (i.e. not properly UTF-8 encoded) it raises UnicodeDecodeError exception:
Am I right that exception handling should be added in
parse_authorization_header()?