-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-56698: Fix base64-url parsing errors in email headers #136830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This looks good to me, but, I'm not the expert here.
@bitdancer, could you take a look whenever you have a bit of time?
What does the RFC says here? should we be strict or not? should it be added as a defect if it fails? |
The RFC states that I believe we should not be strict - as reported in the original bug issue, some mailers use a different alphabet. A defect is indeed added when that happens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should not be strict - as reported in the original bug issue, some mailers use a different alphabet
To be clear: we would still reject the bad alphabet because the first base64.b64decode() with validate=True would fail, and then we try to indicate that there is an error, but at this point, we would still fail because we still can't decode right? (and your PR fixes this path)
b'QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==', | ||
b'Anmeldung Netzanschluss S\xfcdring3p.jpg', | ||
[errors.InvalidBase64CharactersDefect]) | ||
# Mix of 2 base64 alphabets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Mix of 2 base64 alphabets | |
# mix of different base64 alphabets |
I was a bit confused with "2 base64" so let's be a bit more verbose in the comment (in this case the 2 and the 64 from base64 look odd but maybe I'm tired)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
Yes, I believe that description is correct |
Accept urlsafe base64 in email headers, as those are sometimes created by email clients.