[MERGE][#139318] bzr send @ win32: ensure that command line to invoking Thunderbird is 8-bit string, not unicode (because subprocess does not understand non-ascii unicode)

Alexander Belchenko bialix at ukr.net
Wed Feb 27 19:10:27 GMT 2008


Aaron Bentley пишет:
> Alexander Belchenko wrote:
>> This patch fixes problem with UnicodeEncodeError and subprocess module @
>> win32.
> 
> According to my tests, both the encoded and unicode forms are allowed on
> Linux.  So we can encode on all platforms, which should give your change
> better test coverage.
> 
> Also, please include a test case.
> 
> bb:resubmit

Test case provided. I restrict the test for Thunderbird client for now,
because it uses url instead of abs path to attachment. I think I should not
touch paths (neither path to executable nor attachment).

For testing purposes I provide additional wrapping method
_get_compose_8bit_commandline.

Additionally I fix hidden bug in win32_path_to_url function that leads
to force unicode URL for local paths. Test cases provided for posix and
win32 implementations of *_path_to_url.

>> Actually I need this fix only for Thunderbird, default MapiClient is not
>> affected
>> by unicode bug. So if someone think that subject.encode(user_encdoing,
>> 'replace')
>> should be only in Thunderbird class, I'll move it there.
> 
> Actually, it looks like we need to encode all arguments that may be
> provided, so I think the right place would be in
> ExternalMailClient._compose, doing
> 
> cmdline = [a.encode(user_encoding, 'replace') for a in cmdline]
> 
> If you do it there, it's pretty hard to test, so I wouldn't require it.

This approach actually is unsafe because unicode_path.encode(user_encoding, 'replace')
could break absolute unicode paths to executable or attachment.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bugfix.139318.v2.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20080227/c760f508/attachment.diff 


More information about the bazaar mailing list