Tryton - Issues

 

Issue8577

Title Crash when trying to edit an html text with non utf-8 characters
Priority bug Status testing
Superseder Nosy List ced, pokoli, reviewbot
Type crash Components trytond
Assigned To pokoli Keywords review
Reviews 287951002
View: 287951002

Created on 2019-08-15.13:36:55 by pokoli, last changed by ced.

Files
File name Uploaded Type Edit Remove
Nuevo pedido recibido.html pokoli, 2019-08-15.13:36:54 text/plain
Messages
msg51544 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-08-28.20:13:05
I do not think proposal from msg51435 is right. Of course binary can be encoded in any format.
So I really thing the best is to have the HTML editor raised a proper message when encoding is failing.
msg51543 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-08-28.18:49:05
> Then we should probably convert all uploaded files to utf-8.

But we should be able to upload non utf-8 files. For example the account_statement_aeb43 module uses other encoding, and we should allow to upload this file.
msg51436 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-08-23.10:36:05
On 2019-08-23 10:17, Sergi Almacellas Abellana wrote:
> > So you mean that you create report in different encoding then utf-8? 
> 
> Yes, when uploading a file that has no utf-8 encoding.

Tryton has always supported only utf-8.

> > I do not think we should support other encoding.
> 
> Then we should probably convert all uploaded files to utf-8.

But we do not know the encoding. For me, it is the responsibility of the
user to provide binary with proper encoding and format.

I think the best we can do is to provide a page with a proper error
message when editing from HTML editor.
msg51435 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-08-23.10:17:36
> So you mean that you create report in different encoding then utf-8? 

Yes, when uploading a file that has no utf-8 encoding.

> I do not think we should support other encoding.

Then we should probably convert all uploaded files to utf-8.
msg51433 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-08-22.23:09:19
So you mean that you create report in different encoding then utf-8? I do not think we should support other encoding.
review287951002 updated at https://codereview.tryton.org/287951002/#ps285801002
msg51299 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-08-15.13:36:54
Steps to reproduce:

1. Create a new Report from Adminitration -> User Interface -> Actions -> Reports
2. Use the attached file as data and html template extensions. 
3. Once saved use the Edit button to open the template content as HTML. 

An internal server error is shown on the page and the following error is logged on the server:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 66: invalid continuation byte
  File "trytond/protocols/wrappers.py", line 164, in wrapper
    result = func(request, pool, *args, **kwargs)
  File "trytond/ir/routes.py", line 68, in html_editor
    text = text.decode('utf-8')
History
Date User Action Args
2019-08-28 20:13:05cedsetmessages: + msg51544
2019-08-28 18:49:05pokolisetmessages: + msg51543
2019-08-23 10:36:06cedsetmessages: + msg51436
2019-08-23 10:17:37pokolisetmessages: + msg51435
2019-08-22 23:09:20cedsetnosy: + ced
messages: + msg51433
2019-08-15 13:51:53reviewbotsetnosy: + reviewbot
messages: + msg51301
2019-08-15 13:39:30pokolisetstatus: in-progress -> testing
reviews: 287951002
keyword: + review
2019-08-15 13:36:55pokolicreate