openlibhums / openlibhums/janeway
UnicodeDecodeError when clicking edit galley
@ajrbyers is already working on this.
Since Jul 15, 2026.
- Dominant language
- Python
- Stars
- 238
- Forks
- 97
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 8
Description
Describe the bug
When an HTML/XML galley file is uploaded with an encoding different than UTF-8, Janeway will throw a server error if a user tries to edit such galley.: UnicodeDecodeError: 'utf-8' codec can't decode byte [...]
Janeway version
v1.3.8
To Reproduce
Steps to reproduce the behavior:
- Create a non UTF-8 encoded HTML file
- Upload the file as a galley to any article
- Hit edit galley
- See error
Expected behavior
The edit galley page should still resolve properly, perhpas with a message specifying that the encoding of the file is invalid and suggesting the user to upload a properly encoded version of the file.
Additionally we address this problem at upload time, I can think of two approaches:
- Add a form validator that checks the encoding of the file is supported.
- Guess the file encoding with a charset detector and transform it into UTF-8 where possible. This however could lead to data-loss or file corruption if we don't guess the encoding correctly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.