Opened 9 years ago
Closed 8 years ago
#2875 closed bug (Fixed)
WebUI Json dumps Error
Reported by: | yueyoum | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.3.14 |
Component: | Web UI | Version: | 1.3.13 |
Keywords: | Cc: |
Description
when upload torrent via the web ui which the torrent's content contains CJK (Chinese, Japanese, Korea) and not encoding by UTF8,
An Error will occurred at https://github.com/deluge-torrent/deluge/blob/develop/deluge/ui/web/json_api.py#L213
The error message is:
[ERROR ] 11:59:38 json_api:271 'utf8' codec can't decode byte 0xe5 in position 0: invalid continuation byte Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/deluge/ui/web/json_api.py", line 293, in render d = self._on_json_request(request) File "/usr/lib/python2.7/dist-packages/deluge/ui/web/json_api.py", line 265, in _on_json_request return self._send_response(request, response) File "/usr/lib/python2.7/dist-packages/deluge/ui/web/json_api.py", line 276, in _send_response response = json.dumps(response) File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps return _default_encoder.encode(obj) File "/usr/lib/python2.7/json/encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode return _iterencode(o, 0) UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 0: invalid continuation byte
I try to change response = json.dumps(response)
to response = json.dumps(response, ensure_ascii=False)
, this can fix the error.
The torrent in the attach file.
Attachments (1)
Change History (6)
by , 9 years ago
Attachment: | 57a0910dd9608javjunkies.torrent added |
---|
comment:1 by , 8 years ago
Component: | Unknown → Web UI |
---|---|
Milestone: | needs verified → 1.3.14 |
Version: | other (please specify) → 1.3.13 |
comment:3 by , 8 years ago
The error is not due to issues with encoding of the filenames, but because the attached torrent contains an obscure field "filehash" which must be explicitly hex encoded like the sha1 and ed2k fields: https://github.com/deluge-torrent/deluge/blob/develop/deluge/ui/common.py#L115
comment:5 by , 8 years ago
Resolution: | → Fixed |
---|---|
Status: | new → closed |
Fixed in develop [37baf3de3c826] and 1.3-stable [5394ac5604]
I can't reproduce this. Does it give this error with the torrent you attached (with that exact name)?
However, I do get a different error when trying to add the torrent, but that is in bencode.py. Either the torrent is not 100% valid (though Transmission is able to read it), or bencode is buggy.
Edit: Ok, testing with 1.3 gives the expected decoding error