Commit 458b1655 authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

bottle change: when encoding outgoing data, use the surrogateescape error...

bottle change: when encoding outgoing data, use the surrogateescape error handler. This will allow un-decodable file paths through. Esp. useful with errors caused by utf-8 names with apache run in a C locale
parent a7a4dd5c
......@@ -900,7 +900,13 @@ class Bottle(object):
out = out[0][0:0].join(out) # b'abc'[0:0] -> b''
# Encode unicode strings
if isinstance(out, unicode):
out = out.encode(response.charset)
# Jf change: in case python3 encounters un-decodable file
# names, it will use surrogateescape to convert them to
# str. So, use the error handler by default. Apart from
# non-decodable paths, there should be no encoding errors
# at this point, so this should have no general
# consequences.
out = out.encode(response.charset, 'surrogateescape')
# Byte Strings are just returned
if isinstance(out, bytes):
if 'Content-Length' not in response:
......
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