-
-
Notifications
You must be signed in to change notification settings - Fork 2k
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
"Incorrect padding" error on request.post()
#3843
Comments
I see double newlines in the file, but https://tools.ietf.org/html/rfc2045#page-7: "All line breaks or other characters not found in Table 1 must be ignored by decoding software." base64.b64decode(b''.join(binascii.b2a_base64(b'aaa') for i in range(4)).replace(b'\n', b'\x0d\x0d\x0a'))
b'aaaaaaaaaaaa' So, these newlines are not a problem. |
Yes, I also thought that this a problem with breaks \r\r\n, but for some requests this breaks are valid. |
@asvetlov, fix for this problem was written and was merged into master before 3.6.0 release. But all 3.6.x versions don't contain this fix. Could it be added to at least 3.7 release or earlier? |
Long story short
Our clients often send
multipart-form/data
with field decoded in base64 format. For retrieving this data we use on serverawait request.post()
, but sometimes it failed with errorI dived in
Request.post
method and found that aiohttp reads field content using chunks, and every chunk are decoded separately from another chunk. But I did not find that when aiohttp read streaming data there is a rule for a reading chunk with a size that is correct for base64 decoding.Expected behaviour
Expected that request.post decodes multipart-froms with base64 content without errors
Actual behaviour
Throws error about "Incorrect padding"
Steps to reproduce
test-malformed.txt
Your environment
aiohttp.server 3.5.4
Ubuntu 18.04 python3.7
The text was updated successfully, but these errors were encountered: