diff options
author | Russ Cox <rsc@golang.org> | 2009-11-05 18:23:26 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-11-05 18:23:26 -0800 |
commit | b417319449960e7b86143b384cac2e65eddfeda5 (patch) | |
tree | af2dd396d79414c8bfbad145b575d04e0f470c68 /lib/codereview/codereview.py | |
parent | 40c3246c9a7f65328028039633092e7a2074421d (diff) | |
download | golang-b417319449960e7b86143b384cac2e65eddfeda5.tar.gz |
fix UTF-8 upload bug
TBR=r
http://go/go-review/1026001
Diffstat (limited to 'lib/codereview/codereview.py')
-rw-r--r-- | lib/codereview/codereview.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py index 6fc26dd35..00f462181 100644 --- a/lib/codereview/codereview.py +++ b/lib/codereview/codereview.py @@ -36,9 +36,6 @@ For example, if change 123456 contains the files x.go and y.go, "hg diff @123456" is equivalent to"hg diff x.go y.go". ''' -# TODO(rsc): -# fix utf-8 upload bug - from mercurial import cmdutil, commands, hg, util, error, match from mercurial.node import nullrev, hex, nullid, short import os, re @@ -2087,8 +2084,14 @@ def EncodeMultipartFormData(fields, files): lines.append('--' + BOUNDARY) lines.append('Content-Disposition: form-data; name="%s"' % key) lines.append('') + if type(value) == str: + value = value.decode("utf-8") lines.append(value) for (key, filename, value) in files: + if type(filename) == str: + filename = filename.decode("utf-8") + if type(value) == str: + value = value.decode("utf-8") lines.append('--' + BOUNDARY) lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename)) @@ -2099,7 +2102,7 @@ def EncodeMultipartFormData(fields, files): lines.append('') body = CRLF.join(lines) content_type = 'multipart/form-data; boundary=%s' % BOUNDARY - return content_type, body + return content_type, body.encode("utf-8") def GetContentType(filename): |