You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When uploading a UTF-16 Little Endian (without BOM) XML file to a Gitea repository via the web interface, the file is treated as binary, and textual diffs are not displayed. Committing the same file via the command line (or VS Code, which uses the command line) works correctly, with textual diffs shown as expected. This indicates that the issue is specific to the web upload process.
Create a .gitattributes file in the root of the repository with the following content:
*.xml text working-tree-encoding=UTF-16LE eol=crlf
Create an XML file (e.g., test.xml) encoded in UTF-16 Little Endian without a Byte Order Mark (BOM). You can use a text editor like Notepad++ or VS Code to ensure the correct encoding. A simple example file:
Commit and push the .gitattributes and test.xml files using the Git command line:
git add .gitattributes test.xml
git commit -m "Initial commit"
git push origin main # Or your branch name
Modify the XML file locally. Change the attribute value (e.g., from "value1" to "value2"). Save the file (still as UTF-16LE, no BOM).
Upload via the Web UI:
Go to your repository in Gitea's web interface.
Go to the Code tab and locate the xml.
Click the Edit button (pencil icon).
Paste the contents of the modified file.
Add a title to the commit and hit the Commit Changes button.
View the diff: Go to the commit history and view the diff for the uploaded test.xml file.
Expected Behavior
The diff should be displayed as a textual diff, showing the change in the attribute value (e.g., "value1" to "value2").
Actual Behavior
The diff is displayed as a binary diff ("Binary files a/test.xml and b/test.xml differ").
Context
Gitea Version: 1.23.4
Operating System (Gitea Server): Windows Server 2019
Git Version (Server): git version 2.48.1.windows.1
Git Version (Client): git version 2.47.1.windows.1
Browser: Chrome 133
app.ini git section:
[git]MAX_GIT_DIFF_LINES = 200000
MAX_GIT_DIFF_LINE_CHARACTERS = 5000
ENABLE_CHARSET_DETECTION = true
### Gitea Version
1.23.4
### Can you reproduce the bug on the Gitea demo site?
Yes
### Log Gist
https://gist.github.com/kool2zero/ab06322362cdafb7370db3ae3ebfca78
### Screenshots
After creating new branches and commiting via VS Code and the Web.
Initiating a pull request from the VSCode branch:

Diff shows properly:

Trying to initiate the pull request from the UploadFromWeb Branch:

Shows it as a binary file difference:

### Git Version
git version 2.48.1.windows.1
### Operating System
Windows 2019
### How are you running Gitea?
I am using the Windows executable run via NSSM.
### Database
PostgreSQL
The text was updated successfully, but these errors were encountered:
Check the diff between the two auxiliary branches during a pull request. When the file is pushed via vs code, the diff seems to work. When the file is uploaded via the web interface, it does not. The file is treated as binary...
Description
Description
When uploading a UTF-16 Little Endian (without BOM) XML file to a Gitea repository via the web interface, the file is treated as binary, and textual diffs are not displayed. Committing the same file via the command line (or VS Code, which uses the command line) works correctly, with textual diffs shown as expected. This indicates that the issue is specific to the web upload process.
Issue Replicated in Demo
Steps to Reproduce
Create a new Gitea repository.
Create a
.gitattributes
file in the root of the repository with the following content:Create an XML file (e.g.,
test.xml
) encoded in UTF-16 Little Endian without a Byte Order Mark (BOM). You can use a text editor like Notepad++ or VS Code to ensure the correct encoding. A simple example file:Commit and push the
.gitattributes
andtest.xml
files using the Git command line:Modify the XML file locally. Change the attribute value (e.g., from "value1" to "value2"). Save the file (still as UTF-16LE, no BOM).
Upload via the Web UI:
Code
tab and locate the xml.Edit
button (pencil icon).Commit Changes
button.View the diff: Go to the commit history and view the diff for the uploaded
test.xml
file.Expected Behavior
The diff should be displayed as a textual diff, showing the change in the attribute value (e.g., "value1" to "value2").
Actual Behavior
The diff is displayed as a binary diff ("Binary files a/test.xml and b/test.xml differ").
Context
The text was updated successfully, but these errors were encountered: