Skip to content

Commit f550b9b

Browse files
authored
Merge pull request #244 from darosior/redundant_ascii_check
miniscript: remove a redundant check for non-ASCII chars
2 parents 79d5c06 + 45fd438 commit f550b9b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: src/miniscript/mod.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
308308
<Pk as str::FromStr>::Err: ToString,
309309
<<Pk as MiniscriptKey>::Hash as str::FromStr>::Err: ToString,
310310
{
311-
for ch in s.as_bytes() {
312-
if *ch < 20 || *ch > 127 {
313-
return Err(Error::Unprintable(*ch));
314-
}
315-
}
316-
311+
// This checks for invalid ASCII chars
317312
let top = expression::Tree::from_str(s)?;
318313
let ms: Miniscript<Pk, Ctx> = expression::FromTree::from_tree(&top)?;
319314

@@ -898,4 +893,12 @@ mod tests {
898893
))
899894
.is_err());
900895
}
896+
897+
#[test]
898+
fn non_ascii() {
899+
assert!(Segwitv0Script::from_str_insane("🌏")
900+
.unwrap_err()
901+
.to_string()
902+
.contains("unprintable character"));
903+
}
901904
}

0 commit comments

Comments
 (0)