Skip to content

Encode + characters in URLs as %2B #12312

@Turbo87

Description

@Turbo87

Problem

Using unescaped + characters in URLs can cause issues in some scenarios. crates.io currently handles them correctly, but e.g. S3 is not quite following the spec.

cargo currently does not perform any escaping on URLs with + characters in them.

see rust-lang/crates.io#4891

Proposed Solution

The safest way forward would be for cargo to encode + characters as %2B, which should be seen as equivalent by all spec-conforming implementations.

While crates.io can handle + correctly, the current behavior could cause issues during incidents where the download endpoint is switched to target S3 directly.

More information and a detailed investigation is available in rust-lang/crates.io#4891 (comment)

Notes

I guess technically this could be seen as a breaking change, but it could also be interpreted as a low-impact bugfix that would only break third-party registry implementations that didn't follow the spec previously. It might make sense to hide this behind a feature flag initially to give the bigger third-party implementers a chance of testing the change with their infrastructure before it is enabled for everyone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interacts-with-crates.ioArea: interaction with registriesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions