Fix panics parsing regex with whitespace in extended mode by robinst · Pull Request #349 · rust-lang/regex
The added tests fail without the fix like this:
---- parser::tests::ignore_space_escape_hex2 stdout ----
thread 'parser::tests::ignore_space_escape_hex2' panicked at 'called `Result::unwrap()` on an `Err` value: Error { pos: 10, surround: "x 5 3", kind: InvalidBase16(" 5 3") }', src/libcore/result.rs:860
---- parser::tests::ignore_space_escape_hex stdout ----
thread 'parser::tests::ignore_space_escape_hex' panicked at 'called `Result::unwrap()` on an `Err` value: Error { pos: 12, surround: "{ 5 3 }", kind: InvalidBase16(" 5 3") }', src/libcore/result.rs:860
---- parser::tests::ignore_space_ascii_classes stdout ----
thread 'parser::tests::ignore_space_ascii_classes' panicked at 'called `Result::unwrap()` on an `Err` value: Error { pos: 5, surround: "(?x)[ [ : ", kind: UnsupportedClassChar('[') }', src/libcore/result.rs:860
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- parser::tests::ignore_space_escape_octal stdout ----
thread 'parser::tests::ignore_space_escape_octal' panicked at 'valid octal number', src/libcore/option.rs:785
---- parser::tests::ignore_space_escape_unicode_name stdout ----
thread 'parser::tests::ignore_space_escape_unicode_name' panicked at 'called `Result::unwrap()` on an `Err` value: Error { pos: 15, surround: "Y i }", kind: UnrecognizedUnicodeClass(" Y i") }', src/libcore/result.rs:860
---- parser::tests::ignore_space_repeat_counted stdout ----
thread 'parser::tests::ignore_space_repeat_counted' panicked at 'called `Result::unwrap()` on an `Err` value: Error { pos: 15, surround: ", 1 0 }", kind: InvalidBase10("1 0") }', src/libcore/result.rs:860
The reason for the panics is that `bump_get` would ignore space when
walking the characters, but then keep the spaces in the returned String.
Found using cargo-fuzz.