Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes_regex() only allows regexs that match valid UTF-8 #238

Closed
hkratz opened this issue May 8, 2021 · 2 comments
Closed

bytes_regex() only allows regexs that match valid UTF-8 #238

hkratz opened this issue May 8, 2021 · 2 comments
Labels
duplicate This issue has been reported somewhere else

Comments

@hkratz
Copy link

hkratz commented May 8, 2021

Proptests trying to generate invalid UTF-8 sequences with bytes_regex() result in an error.

Source:

proptest! {
    #[test]
    fn simple_invalid_prop(ref input in bytes_regex(r"(?-u)\xFF").unwrap()) {
    }
}

Error:

---- tests::simple_invalid_prop stdout ----
thread 'tests::simple_invalid_prop' panicked at 'called `Result::unwrap()` on an `Err` value: RegexSyntax(Translate(Error { kind: InvalidUtf8, pattern: "(?-u)\\xFF", span: Span(Position(o: 5, l: 1, c: 6), Position(o: 9, l: 1, c: 10)) }))', src\tests.rs:239:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This makes them much less useful in practice. Maybe creating a parser with regex_syntax::ParserBuilder::allow_invalid_utf8() set to true is sufficient to fix this.

@hkratz hkratz changed the title byte_regex() only allows regexs that match valid UTF-8 bytes_regex() only allows regexs that match valid UTF-8 May 8, 2021
@zackw
Copy link
Contributor

zackw commented Jun 30, 2023

Whoops, this is exactly the same as #336. I should have looked more carefully at the issue list before filing that one.

@matthew-russo matthew-russo added the duplicate This issue has been reported somewhere else label Jul 1, 2023
@matthew-russo
Copy link
Member

closing this as duplicate. #336 will be used for tracking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue has been reported somewhere else
Projects
None yet
Development

No branches or pull requests

3 participants