Skip to content

cargo install --git accepts malformed URL with #, discards it for cloning, then re-adds it into crates.toml #15336

Open
@nabijaczleweli

Description

@nabijaczleweli

Problem

Downstream report: nabijaczleweli/cargo-update#293 (comment)

Steps

  1. cargo install --git https://github.com/simonrupf/convert2json.git#65d1408a46668787ba34bf10134ac767c5035710
  2. grep convert2json ~/.cargo/crates.toml
  3. "convert2json 1.1.6 (git+https://github.com/simonrupf/convert2json.git#65d1408a46668787ba34bf10134ac767c5035710#74a150d03308dee5a084469ca57623e62560b60b)" = [

Possible Solution(s)

Either parse the "anchor" as the rev or don't discard it, since cloning a URL like this is actually illegal

$ git clone https://github.com/simonrupf/convert2json.git#65d1408a46668787ba34bf10134ac767c5035710
Cloning into 'convert2json.git#65d1408a46668787ba34bf10134ac767c5035710'...
fatal: unable to update url base from redirection:
  asked for: https://github.com/simonrupf/convert2json.git#65d1408a46668787ba34bf10134ac767c5035710/info/refs?service=git-upload-pack
   redirect: https://github.com/simonrupf/convert2json

Notes

No response

Version

cargo 1.85.1 (d73d2caf9 2024-12-31) I think, the original reporter didn't say.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-gitArea: anything dealing with gitC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions