Single FIle Editor removes UTF-8 BOM
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When a user uses the "single file editor" to change a file that has been encoded in UTF-8 with BOM (byte order mark), it removes the BOM.
This was previously reported as a bug with the WebIDE (#358282 (closed)), but our switch to VSCode fixed that. However, the single file editor still exhibits this problem.
Steps to reproduce
- Create a UTF-8 file with BOM locally and commit it to the repository.
- Push the repo to GitLab.
- In the GitLab UI, edit the file using the Single File Editor and make any changes to a line other than the first line.
- Commit to a new branch and open an MR.
- Check the diff. You will see that the first line of the file is changed, even though you didn't change it. This is the BOM being removed.
- Merge the MR and pull the repo to find that the BOM has indeed been removed.
Example Project
ahanselka/single-file-editor-bom-test!1
What is the current bug behavior?
The BOM is discarded from the file after editing with the single file editor.
What is the expected correct behavior?
The BOM should be left entirely unchanged.
Relevant logs and/or screenshots
Here we can see that on the main
branch, the file has a BOM.
~/code/single-file-editor-bom-test ‹main› % file README.md
README.md: Unicode text, UTF-8 (with BOM) text, with very long lines (535)
Here is my local checkout of the test branch from the MR above:
~/code/single-file-editor-bom-test ‹edit-file› % file README.md
README.md: ASCII text, with very long lines (535)
Output of checks
This bug happens on GitLab.com
Possible fixes
Edited by 🤖 GitLab Bot 🤖