openlibhums / imports

A plugin for importing content into Janeway.
GNU Affero General Public License v3.0
1 stars 2 forks source link

Error during template rendering in template of csv unicodedecodeerror #11

Closed hachacha closed 2 years ago

hachacha commented 3 years ago

On Article Metadata upload, it refused to render the "example/preview" page of the csv after uploading. I was able to get around it by adding file = open(path, 'r', encoding="utf-8") on the import_action function within views.py

The strange thing is that this didn't happen on my local which is just run from runserver but it did happen on the staging server -- Aapache and Ubuntu 18.04. Any thoughts about this? Is the fix appropriate or should people be limited to a certain character set?

mauromsl commented 3 years ago

Yes, we should always assume UTF-8 encoding for web uploads (and probably return an error message when not, instead of raising a 500), so setting the encoding when calling open() would be best.

Your Ubuntu system probably has set the locale enviroment variables to something other than UTF-8.