Skip to content

git-upload-pack strips leading / only when single-quoted #12471

Closed
@ninewise

Description

@ninewise
  • Gitea version (or commit ref): v1.12.2
  • Git version: 2.26.2
  • Operating system: Alpine Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite

Description

Creating this issue for a friend without github.

This line replaces first ocurrence of '/ with ' from parameter. This works for cloning the repository with git over SSH, as the remote command gets executed as git-upload-pack '/user/repo' (strace shows this clearly). In that case, said function rewrites it to git-upload-pack 'user/repo' and later on it gets correctly split in user and repo. Now, there are other implementations of Git which doesn't send the commands in that precise way, but as command git-upload-pack with parameter /user/repo (note no single-quotes). Got is one of such implementations, which can't clone the repo as it fails here.

I think the intended behaviour is to remove any leading / from the parameter, quoted or not. Most correct solution would be using a shell quoting library to normalize the input and then remove the leading /. Alternatively, for a quick fix, removing the replace in parseCmd and changing line 144 to also trim / should do the trick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions