pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

Regex Matcher Fails On Valid Inputs #214

Closed adamrodger closed 1 year ago

adamrodger commented 2 years ago

The regex library used by pact_matching fails on valid input. Take the following example:

use onig::Regex;

fn main() {
    let regex_string = "Greater|GreaterOrEqual";

    let re = Regex::new(regex_string).unwrap();

    println!("Regex: {regex_string}");
    check(&re, "Greater");
    check(&re, "GreaterOrEqual");
}

fn check(regex: &Regex, input: &str) {
    let matched = regex.is_match(input);
    println!("Input: {input} - {matched}");
}

This produces the output:

Regex: Greater|GreaterOrEqual
Input: Greater - true
Input: GreaterOrEqual - false

If you swap the regex around to the opposite order then it passes:

Regex: GreaterOrEqual|Greater
Input: Greater - true
Input: GreaterOrEqual - true
adamrodger commented 2 years ago

Upstream issue: https://github.com/rust-onig/rust-onig/issues/171

mefellows commented 1 year ago

Looks like this needs testing before we can version bump it: https://github.com/rust-onig/rust-onig/pull/172#issuecomment-1231969268

rholshausen commented 1 year ago

I tested onig master branch, and it fixes this issue