Skip to content
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

Consider sanitizing filenames for whitespaces when creating a file from web interface #31478

Open
diamante0018 opened this issue Jun 24, 2024 · 1 comment · May be fixed by #31507
Open

Consider sanitizing filenames for whitespaces when creating a file from web interface #31478

diamante0018 opened this issue Jun 24, 2024 · 1 comment · May be fixed by #31507
Labels

Comments

@diamante0018
Copy link

Description

When creating a filename using the website you may accidentally add whitespace to the filename which can lead to unexpected events, attempting to clone a repo which contains a file that has a trailing whitespace on Windows leads to this error:

git clone https://demo.gitea.com/future/test-filename.git
Cloning into 'test-filename'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
error: invalid path 'there-is-a-whitespace '
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

This leads me to open this discussion to see if it's worth asking the gitea devs to perform whitespace removal (trim) at both the end and start of the filename string so this can be prevented automatically.

Gitea Version

1.23.0+dev-273-ga4899ffa24

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

test2
test1

Git Version

demo.gitea.com

Operating System

demo.gitea.com

How are you running Gitea?

demo.gitea.com

Database

None

@yp05327
Copy link
Contributor

yp05327 commented Jun 27, 2024

Maybe we need a IsVaildFileName in backend, as it is not checked now and already caused some problems like #29907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants