Skip to content

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

Closed
@diamante0018

Description

@diamante0018

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions