phylum-dev / purl Goto Github PK
View Code? Open in Web Editor NEWPackage URL implementation for Rust
License: MIT License
Package URL implementation for Rust
License: MIT License
pkg:brew/openssl%[email protected]
parses correctly but then incorrectly serializes as pkg:brew/openssl%[email protected]
(openssl%401.1
turns into [email protected]
).
Percent signs in input should be percent encoded such that the serializing the PURL and parsing it again produces the same result.
althonos/packageurl.rs has the same problem, probably because both implementations use the same crate for encoding. It's surprising that the percent_encoding
crate does not automatically percent encode percent signs since encoding a string containing percent signs and not encoding the percent signs can change the meaning of the string. servo/rust-url#822 says this is the expected behavior, but then how it's supposed to work is unclear.
The URL spec says
Of the possible values for the percentEncodeSet argument only two end up encoding U+0025 (%) and thus give “roundtripable data”: component percent-encode set and application/x-www-form-urlencoded percent-encode set. The other values for the percentEncodeSet argument — which happen to be used by the URL parser — leave U+0025 (%) untouched and as such it needs to be percent-encoded first in order to be properly represented.
Does that mean when serializing you're expected to percent encode everything twice? Once just for percent signs and then once for everything else? What is the difference between that and having percent in the percent encode set to begin with? Is it because the URL spec works with partially decoded strings so those encodings happen at different times?
builder.with_qualifier("vcs_url", "git+https://github.com/rustsec/rustsec.git@6f82509cb43a");
ends up encoded as vcs_url=git+https://github.com/rustsec/rustsec.git%406f82509cb43a
- note the non-escaped +
symbol.
By contrast, the official spec provides an example where the +
sign is percent-encoded: pkg:generic/bitwarderl?vcs_url=git%2Bhttps://git.fsfe.org/dxtr/bitwarderl%40cc55108da32
The correct percent encoding character set for URL parameters being used, matching the URL and PURL specifications.
When added as a dependency in another project with default-features = false
, or when running cargo build --no-default-features
, the crate fails to build:
error[E0432]: unresolved import `smartstring`
--> /home/shnatsel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/purl-0.1.1/src/lib.rs:12:5
|
12 | use smartstring::{LazyCompact, SmartString, SmartStringMode};
| ^^^^^^^^^^^ use of undeclared crate or module `smartstring`
For more information about this error, try `rustc --explain E0432`.
Steps to reproduce this behavior:
cargo build --no-default-features
No compilation failures
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.