Skip to content

Commit 8dd4a21

Browse files
authored
Merge pull request RGB-WG#209 from RGB-WG/invoice/uri
Require invoice URIs not to contain authority
2 parents 247a103 + bc12d97 commit 8dd4a21

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

invoice/src/parse.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ pub enum InvoiceParseError {
7575
/// invalid invoice.
7676
Invalid,
7777

78+
/// RGB invoice must not contain any URI authority data, including empty
79+
/// one.
80+
Authority,
81+
7882
/// contract id is missed from the invoice.
7983
ContractMissed,
8084

@@ -349,7 +353,12 @@ impl FromStr for RgbInvoice {
349353
return Err(InvoiceParseError::InvalidScheme(scheme.to_string()));
350354
}
351355

352-
let mut path = uri.path().segments();
356+
let path = uri.path();
357+
if path.is_absolute() || uri.auth.is_some() {
358+
return Err(InvoiceParseError::Authority);
359+
}
360+
361+
let mut path = path.segments();
353362

354363
let Some(contract_id_str) = path.next() else {
355364
return Err(InvoiceParseError::ContractMissed);

0 commit comments

Comments
 (0)