Skip to content

Commit

Permalink
Restrict control characters in regex insted of using filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
SRv6d committed Sep 28, 2024
1 parent 751bf2f commit 870cb1b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions tests/test_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ mod strategies {
/// An attribute value may consist of any characters from the extended ASCII set,
/// while excluding control and not starting with, or consisting entirely of whitespace.
fn attribute_value_content() -> impl Strategy<Value = String> {
proptest::string::string_regex(r"[\x00-\xFF]+")
proptest::string::string_regex(r"[\x20-\x7E\x80-\xFF]+")
.unwrap()
.prop_filter("Cannot start with whitespace", |s| {
!s.starts_with(|c: char| c.is_whitespace())
})
.prop_filter("Cannot consist of whitespace only", |s| {
!s.trim().is_empty()
})
.prop_filter("Cannot contain control characters", |s| {
!s.chars().any(|c| c.is_control())
})
}

/// An empty attribute value.
Expand Down

0 comments on commit 870cb1b

Please sign in to comment.