Skip to content

"invisible Unicode characters"-warning for carriage return characters in files with CRLF newlines #27091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anthonyvdotbe opened this issue Sep 15, 2023 · 4 comments
Labels

Comments

@anthonyvdotbe
Copy link
Contributor

anthonyvdotbe commented Sep 15, 2023

Description

Files with Windows newlines (CRLF) give the warning:

This file contains invisible Unicode characters!

and when clicking Escape, the CR characters are marked as problematic.

Gitea Version

1.20.4

Can you reproduce the bug on the Gitea demo site?

The site was unreachable when filing the issue.

Log Gist

No response

Screenshots

image

Git Version

2.41 (git version 2.41.0.windows.1)

Operating System

Windows 11 (Microsoft Windows 10.0.22621)

How are you running Gitea?

Using the official gitea-1.20.4-windows-4.0-amd64.exe, running as a Windows service as described in the Gitea docs.

Database

SQLite

@lng2020
Copy link
Member

lng2020 commented Sep 19, 2023

I would rather not call this as a bug.
If you upload README with git and set core.autocrlf as true(default setting) or edit README via Gitea web editor, those CRLF will auto-translate into LF, so It won't be a problem. And if the filename is not README, the Gitea file viewer will not show an error, as shown in the screenshot below.
ksnip_20230919-175122
So this error only occurs when uploading README via git and core.autocrlf is false or uploading README through the Gitea upload file button. I think it's reasonable to warn users because most of README use LF.
(BTW, as I tested in Github today, uploading the README file through the Github upload file button in Windows will encounter 400 bad request error...)

@anthonyvdotbe
Copy link
Contributor Author

anthonyvdotbe commented Sep 19, 2023

The exception for files named README seems arbitrary to me. I don't think Gitea should be opinionated about newlines at all (even more so because the local Git installation that Gitea uses, has core.autocrlf set to false).

And I'm very surprised to find out that Gitea quietly converts newlines of existing files when editing via the web interface. To me this is a bug as well.

I just tried with GitHub: create a repository, upload a file named README.html containing CRLF newlines via the web interface, download the same file again via the web interface: everything went without errors and the redownloaded file still has CRLF newlines. So GitHub didn't change the newlines and works as I'd expect Gitea to work as well.

@lng2020
Copy link
Member

lng2020 commented Sep 19, 2023

I just tried with GitHub: create a repository, upload a file named README.html containing CRLF newlines via the web interface, download the same file again via the web interface: everything went without errors and the redownloaded file still has CRLF newlines. So GitHub didn't change the newlines and works as I'd expect Gitea to work as well.

Actually, as I mentioned before, Gitea won't change this as well. The translation only happens when you edit file with the Gitea web interface.

@lng2020
Copy link
Member

lng2020 commented Oct 23, 2023

So now Gitea won't change the file content or show an error message with CRLF. So I'm closing it.

@lng2020 lng2020 closed this as completed Oct 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants