Skip to content

Commit

Permalink
Ignore RFC 3986 fragments in BIP 21 URIs
Browse files Browse the repository at this point in the history
Although behavior for when encountering RFC 3986 fragments in BIP 21
URIs is not specified, according to RFC 3986 it is unambiguously not
query data and therefore should be excluded from BIP 21 query
parameters.

[WIP] squash with parent commits:
c88442f failing test that fragments aren't parsed for params
51f8b88 failing test that fragment separator is ignored
  • Loading branch information
nothingmuch committed Oct 21, 2024
1 parent c88442f commit 8a1a580
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ impl<'a, T: DeserializeParams<'a>> Uri<'a, bitcoin::address::NetworkUnchecked, T
let mut label = None;
let mut message = None;
if let Some(params) = params {
// [RFC 3986 § 3.4](https://www.rfc-editor.org/rfc/rfc3986#section-3.4):
//
// > The query component is indicated by the first question
// > mark ("?") character and terminated by a number sign ("#") character
// > or by the end of the URI.
let params = match params.find('#') {
Some(pos) => &params[..pos],
None => params,
};

for param in params.split('&') {
let pos = param
.find('=')
Expand Down

0 comments on commit 8a1a580

Please sign in to comment.