Opened 8 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:


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

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/", line 293, in render
    d = self._on_json_request(request)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/web/", line 265, in _on_json_request
    return self._send_response(request, response)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/web/", line 276, in _send_response
    response = json.dumps(response)
  File "/usr/lib/python2.7/json/", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/", 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)

57a0910dd9608javjunkies.torrent (97.7 KB) - added by yueyoum 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by yueyoum

comment:1 Changed 8 years ago by Cas

  • Component changed from Unknown to Web UI
  • Milestone changed from needs verified to 1.3.14
  • Version changed from other (please specify) to 1.3.13

comment:2 Changed 8 years ago by bro

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 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

Last edited 8 years ago by bro (previous) (diff)

comment:3 Changed 8 years ago by bro

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:

comment:4 Changed 8 years ago by bro

yueyoum, is the content in the torrent copyrighted?

comment:5 Changed 8 years ago by Cas

  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in develop [37baf3de3c826] and 1.3-stable [5394ac5604]

Note: See TracTickets for help on using tickets.