Repository navigation
fix(make-mime): preserve non-ASCII attachment filenames - #7071
Conversation
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
|
Hi @blackboxsw, this PR is ready for review. Could you please take a look when you have a chance? Thank you! |
nryanl
left a comment
There was a problem hiding this comment.
Hey there, thanks for your contribution!
I'm happy with the fix here. For your test: I wonder if we should add coverage between encode and decode as well. If not only just to test the intermediate representation, but it would also catch future changes to the default header encoding elsewhere. What do you think?
Something like this:
[attachment] = parsed.get_payload()
assert attachment.get_filename() == filename
disposition = attachment["Content-Disposition"]
if filename.isascii():
assert 'filename="' in disposition
assert "filename*=" not in disposition
else:
assert "filename*=utf-8''" in dispositionThanks again!
789496b to
8019abf
Compare
|
Good point, thanks! I added the Content-Disposition assertions, rebased onto the latest main, and pushed the update. All tests pass locally. Could you take another look? |
Proposed Commit Message
Additional Context
make-mimeloses filenames such ascafé.yamlandإعداد.yamlwhen its output is parsed:get_filename()returnsNone, andUserDataProcessorsubstitutespart-001. The attachment content is preserved.Pass
filenameseparately toadd_headerso Python applies RFC 2231 encoding, matching the existing pattern incloudinit/user_data.py. No CLI options change.Test Steps
check_formatremains unsuccessful locally: Python 3.12 reports PylintE1120incloudinit/util.py:2142(also reproduced on unmodifiedmain), while Python 3.14 reports missingcryptimports in unchanged files.CLI reproduction
Run from the checkout after creating the tox test environment. No VM is required.
Before the fix, the filename assertion fails because the parsed filename is
None. Afterward, both assertions pass. Temporary files are cleaned up automatically.Merge type