Skip to content

Commit

Permalink
Fix exceptions raised by decode_request
Browse files Browse the repository at this point in the history
  • Loading branch information
Unrud committed Sep 14, 2020
1 parent 6f3a952 commit 8008b36
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion radicale/httputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ def decode_request(configuration, environ, text):
# Then append various fallbacks
charsets.append("utf-8")
charsets.append("iso8859-1")
# Remove duplicates
for i, s in reversed(list(enumerate(charsets))):
if s in charsets[:i]:
del charsets[i]

# Try to decode
for charset in charsets:
try:
return text.decode(charset)
except UnicodeDecodeError:
pass
raise UnicodeDecodeError
raise UnicodeDecodeError("decode_request", text, 0, len(text),
"all codecs failed [%s]" % ", ".join(charsets))


def read_raw_request_body(configuration, environ):
Expand Down

0 comments on commit 8008b36

Please sign in to comment.