You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parse_authorization_header raises UnicodeDecodeError, not returning None #1816
This is an issue with how you constructed the header, you relied on whatever encoding your local machine was set to rather than using 'utf-8'. I don't think this needs to be handled in Werkzeug as it shouldn't come up in normal use and would indicate an issue with the client if the encoding it sends doesn't decode the bytes.
This is an issue with how you constructed the header, you relied on whatever encoding your local machine was set to rather than using 'utf-8'. I don't think this needs to be handled in Werkzeug as it shouldn't come up in normal use and would indicate an issue with the client if the encoding it sends doesn't decode the bytes.
Such behaviour differs from docstring. In fact Authorization header is improperly formatted and invalid.
Imagine you have a production server and someone sends auth requests using improperly formatted header. Correct behaviour will be to reply with 401 which in turn generated using None response taken from parse_authorization_header().
I.e. Flask-login uses Flask request.authorization which in turn uses parse_authorization_header().
In result you get UnicodeDecodeError rather than 401.
changed the title [-]parse_authorization_header raises UnicodeEncodeError, not returning None[/-][+]parse_authorization_header raises UnicodeDecodeError, not returning None[/+]on May 26, 2020
Activity
davidism commentedon May 26, 2020
This is an issue with how you constructed the header, you relied on whatever encoding your local machine was set to rather than using 'utf-8'. I don't think this needs to be handled in Werkzeug as it shouldn't come up in normal use and would indicate an issue with the client if the encoding it sends doesn't decode the bytes.
ArchibaldArt commentedon May 26, 2020
Such behaviour differs from docstring. In fact Authorization header is improperly formatted and invalid.
Imagine you have a production server and someone sends auth requests using improperly formatted header. Correct behaviour will be to reply with 401 which in turn generated using
Noneresponse taken fromparse_authorization_header().I.e.
Flask-loginuses Flaskrequest.authorizationwhich in turn uses parse_authorization_header().In result you get UnicodeDecodeError rather than 401.
[-]parse_authorization_header raises UnicodeEncodeError, not returning None[/-][+]parse_authorization_header raises UnicodeDecodeError, not returning None[/+]mitsuhiko commentedon May 28, 2020
The server should not crash as a result of the client sending bad data. This is indeed a bug in the function that should be fixed.