Encoding problem when editing files in GitLab
Summary
Steps to reproduce
- Create a repository
- Configure the .gitattribute with *.pas text working-tree-encoding=windows-1252
- Create a ANSI file in your computer with some accentuation
- Upload to the repository
- Edit the file in GitLab
- The file has been corrupted
Example Project
https://gitlab.com/samuel.andrade/teste/-/tree/main/ The file ansi.pas is what i tested
What is the current bug behavior?
Files that have been configured in .gitattributes with working-tree-encoding=windows-1252, when edited in GitLab gets corrupted
What is the expected correct behavior?
Before saving the files, convert backwards to windows-1252
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
When some file is defined with .gitattributes to working-tree-encoding=windows-1252, we cannot save the file in any editor of gitlab.com
I have in my .gitattributes these lines
*.pas text working-tree-encoding=windows-1252 *.dpr text working-tree-encoding=windows-1252 *.dproj text working-tree-encoding=windows-1252 *.dfm text working-tree-encoding=windows-1252 *.iss text working-tree-encoding=windows-1252 *.ps1 text working-tree-encoding=windows-1252 *.elo text working-tree-encoding=windows-1252
And, when i try to apply some suggestion or edit the file directly in gitlab.com it get corrupted. For example: //UTF-8 é super estimado becames //UTF-8 é super estimado
Possible fixes
I believe that the file has been converted to UTF-8 to be able to show in the site, but it is not being conveted backwards to windows-1252. I believe that it is needed to converte from UTF-8 to the original encoding before saving.