diff options
author | Colin Walters <walters@verbum.org> | 2010-11-01 14:58:26 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2011-04-27 13:26:43 -0400 |
commit | d031efd02ae8c145cd5df126da53936fbd450a42 (patch) | |
tree | c9686c4b5eb8f3e582561bb95f35b6a51833c05a | |
parent | 9cf4811c355c846a1a9343cac537f4ff6669b651 (diff) |
Support UTF-8 attachments
The cookies were being pulled out of Sqlite were Unicode, which
caused the entire HTTP buffer to be Unicode. When concatenating
non-ascii string instances (as would be returned from e.g. git),
things blew up.
Ensure the cookie data is UTF-8 str, and also set our content
encoding explicitly to UTF-8.
https://bugzilla.gnome.org/show_bug.cgi?id=633729
-rwxr-xr-x | git-bz | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -839,7 +839,10 @@ class BugServer(object): def send_request(self, method, url, data=None, headers={}): headers = dict(headers) - headers['Cookie'] = self.get_cookie_string() + cookies = self.get_cookie_string() + if isinstance(cookies, unicode): + cookies = cookies.encode('UTF-8') + headers['Cookie'] = cookies headers['User-Agent'] = "git-bz" if self.auth_user and self.auth_password: headers['Authorization'] = http_auth_header(self.auth_user, self.auth_password) @@ -958,7 +961,10 @@ class BugServer(object): class CookieTransportMixin(object): def send_request(self, connection, *args): xmlrpclib.Transport.send_request(self, connection, *args) - connection.putheader("Cookie", self.server.get_cookie_string()) + cookie = self.server.get_cookie_string() + if isinstance(cookie, unicode): + cookie = cookie.encode('UTF-8') + connection.putheader("Cookie", cookie) connection.putheader("Authorization", http_auth_header(self.server.auth_user, self.server.auth_password)) class BugTransport(CookieTransportMixin, xmlrpclib.Transport): @@ -1152,7 +1158,7 @@ class Bug(object): # name 'obsolete' for each item in the list fields['obsolete'] = map(str, obsoletes) - files = { 'data': (filename, 'text/plain', data) } + files = { 'data': (filename, 'text/plain; charset=UTF-8', data) } response = self.server.send_post("/attachment.cgi", fields, files) response_data = response.read() |