Repository navigation
Address #17 follow-ups to prep release 0.2.0 - #18
Conversation
Uri::parse stops reading parameters at the first # after the ?, so an unencoded # inside a value truncates it and silently drops every parameter after it. A BIP 77 pj URL carries its keys in a fragment, so this is the case a payjoin sender hits. Say so in the parse docs, and that the fix is to write # as %23. unsatisfied_requirements reports req-amount, req-label and the other keys this crate parses unless the caller lists them, because parsing a value is not acting on it. Say so in its docs and in the example, which a wallet copying it would otherwise get wrong.
std is not a default feature, so cargo test alone never builds the std code paths. Run the tests a second time with --all-features on every toolchain in the matrix, including the 1.63 job.
Uri::parse matches keys literally, so %61mount is an unknown key, not amount. RFC 3986 section 2.3 makes the two equivalent, though, so a reader that decodes keys before matching would see amount. A URI with an escaped key means different things to different parsers. The builder used to accept a key with valid escapes. Reject any % in a key instead, so a URI this crate builds never carries that ambiguity. Raw values still take escapes.
Turn the Unreleased section into 0.2.0 and rewrite it for someone upgrading from 0.1. The main thing a 0.1 user has to act on was missing: 0.1 rejected an unknown req- parameter at parse time, and 0.2 parses it and leaves the check to unsatisfied_requirements. Also list the removed fields, constructors and types, the case-insensitive keys, and the stricter bc/tb/bcrt values. Point the README at the changelog instead of calling 0.2 unstable, and add bip321 to the crate keywords.
caarloshenriq
left a comment
There was a problem hiding this comment.
ACK 4735116
Checked the new # docs against the parser: an unencoded # in pj drops the amount and label after it, and %23 keeps all three. Every symbol the changelog names exists and is exported
Thanks for taking the req- note. One small question inline about escaped keys on the parse side
| /// emitting an escape in a key keeps every reader on the same meaning. | ||
| fn key_round_trips(key: &str) -> bool { | ||
| is_qchars(key) && !params::base_key(key).is_empty() | ||
| is_qchars(key) && !key.contains('%') && !params::base_key(key).is_empty() |
There was a problem hiding this comment.
Makes sense for the builder. On the parse side, Uri::parse still takes %61mount=1 as an unknown key, so this crate ignores it while a reader that decodes keys sees an amount. Rejecting it at parse time would probably go against BIP 321’s grammar, but a line in the parse docs, like the new one about #, would tell consumers about that divergence. Not blocking.
There was a problem hiding this comment.
Please feel free to pr as a follow-up since this can be in a patch release
Follow up #17 with @benalleng 's requested changes
Pinging @caarloshenriq for parallel review because this builds on a lot of his work
Co-authored with Claude Code