Skip to content

Regex::is_match unexpectedly returning false with regex-syntax v0.8.0Β #1103

@edmorley

Description

@edmorley

Hi πŸ˜„

First, thank you for a fantastic crate!

What version of regex are you using?

$ cargo tree
testcasev0.1.0 (/Users/emorley/src/testcase)
└── regex v1.10.0
    β”œβ”€β”€ aho-corasick v1.1.2
    β”‚   └── memchr v2.6.4
    β”œβ”€β”€ memchr v2.6.4
    β”œβ”€β”€ regex-automata v0.4.1
    β”‚   β”œβ”€β”€ aho-corasick v1.1.2 (*)
    β”‚   β”œβ”€β”€ memchr v2.6.4
    β”‚   └── regex-syntax v0.8.0
    └── regex-syntax v0.8.0

Describe the bug at a high level.

Using regex-syntax v0.8.0, a Regex::is_match that previously matched in regex-syntax v0.7.4 no longer matches.

Whilst the issue no longer reproduces as part of the regex-syntax v0.8.1 release (I would guess due to the revert in that release: #1102), I thought you might still wish to see the testcase in case it covers something that the newly added fuzz tests do not, ready for the future relanding of #1051.

What are the steps to reproduce the behavior?

  1. cargo new testcase && cd $_
  2. cargo add regex@1.10.0
  3. cargo update -p regex-syntax --precise 0.8.0
  4. Add this to the end of main.rs:
    #[cfg(test)]
    mod tests {
        #[test]
        fn testcase() {
            assert!(regex::Regex::new(r"^[[:alnum:]./-]+$")
                .unwrap()
                .is_match("a-b"));
        }
    }
  5. cargo test
  6. cargo update -p regex-syntax --precise 0.8.1
  7. cargo test

What is the actual behavior?

  • cargo test at step 5 (ie: when using regex-syntax v0.8.0) fails with the output below
  • cargo test at step 7 (ie: when using regex-syntax v0.8.1) passes
---- tests::testcase stdout ----
thread 'tests::testcase' panicked at src/main.rs:9:9:
assertion failed: regex::Regex::new(r\"^[[:alnum:]./-]+$\").unwrap().is_match(\"a-b\")

What is the expected behavior?

cargo test passes regardless of regex-syntax version.

Notes

  • I'm using Rust 1.74.0-beta.1 on macOS on ARM
  • If I replace the [:alnum:] in the regex with eg a-z then the issue stops reproducing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions