Kaydet (Commit) 4cdceac7 authored tarafından Georg Brandl's avatar Georg Brandl

Fix #883466: don't allow Unicode as arguments to quopri and uu codecs.

üst 38f1b98c
...@@ -18,7 +18,8 @@ def quopri_encode(input, errors='strict'): ...@@ -18,7 +18,8 @@ def quopri_encode(input, errors='strict'):
""" """
assert errors == 'strict' assert errors == 'strict'
f = StringIO(input) # using str() because of cStringIO's Unicode undesired Unicode behavior.
f = StringIO(str(input))
g = StringIO() g = StringIO()
quopri.encode(f, g, 1) quopri.encode(f, g, 1)
output = g.getvalue() output = g.getvalue()
...@@ -33,7 +34,7 @@ def quopri_decode(input, errors='strict'): ...@@ -33,7 +34,7 @@ def quopri_decode(input, errors='strict'):
""" """
assert errors == 'strict' assert errors == 'strict'
f = StringIO(input) f = StringIO(str(input))
g = StringIO() g = StringIO()
quopri.decode(f, g) quopri.decode(f, g)
output = g.getvalue() output = g.getvalue()
......
...@@ -25,7 +25,8 @@ def uu_encode(input,errors='strict',filename='<data>',mode=0666): ...@@ -25,7 +25,8 @@ def uu_encode(input,errors='strict',filename='<data>',mode=0666):
assert errors == 'strict' assert errors == 'strict'
from cStringIO import StringIO from cStringIO import StringIO
from binascii import b2a_uu from binascii import b2a_uu
infile = StringIO(input) # using str() because of cStringIO's Unicode undesired Unicode behavior.
infile = StringIO(str(input))
outfile = StringIO() outfile = StringIO()
read = infile.read read = infile.read
write = outfile.write write = outfile.write
...@@ -60,7 +61,7 @@ def uu_decode(input,errors='strict'): ...@@ -60,7 +61,7 @@ def uu_decode(input,errors='strict'):
assert errors == 'strict' assert errors == 'strict'
from cStringIO import StringIO from cStringIO import StringIO
from binascii import a2b_uu from binascii import a2b_uu
infile = StringIO(input) infile = StringIO(str(input))
outfile = StringIO() outfile = StringIO()
readline = infile.readline readline = infile.readline
write = outfile.write write = outfile.write
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment