Skip to content

Commit

Permalink
Merge pull request #244 from darosior/redundant_ascii_check
Browse files Browse the repository at this point in the history
miniscript: remove a redundant check for non-ASCII chars
  • Loading branch information
apoelstra authored Apr 27, 2021
2 parents 79d5c06 + 45fd438 commit f550b9b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
<Pk as str::FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as str::FromStr>::Err: ToString,
{
for ch in s.as_bytes() {
if *ch < 20 || *ch > 127 {
return Err(Error::Unprintable(*ch));
}
}

// This checks for invalid ASCII chars
let top = expression::Tree::from_str(s)?;
let ms: Miniscript<Pk, Ctx> = expression::FromTree::from_tree(&top)?;

Expand Down Expand Up @@ -898,4 +893,12 @@ mod tests {
))
.is_err());
}

#[test]
fn non_ascii() {
assert!(Segwitv0Script::from_str_insane("🌏")
.unwrap_err()
.to_string()
.contains("unprintable character"));
}
}

0 comments on commit f550b9b

Please sign in to comment.