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

Panic when parsing "(?m){1,1}" #555

Closed
adamcrume opened this issue Jan 27, 2019 · 0 comments
Closed

Panic when parsing "(?m){1,1}" #555

adamcrume opened this issue Jan 27, 2019 · 0 comments
Labels

Comments

@adamcrume
Copy link
Contributor

Parsing "(?m){1,1}" with regex-syntax 0.6.5 results in:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:355:21                                                                       
stack backtrace:                           
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace                       
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                     
   1: std::sys_common::backtrace::_print   
             at src/libstd/sys_common/backtrace.rs:71                                 
   2: std::panicking::default_hook::{{closure}}                                       
             at src/libstd/sys_common/backtrace.rs:59                                 
             at src/libstd/panicking.rs:211                                           
   3: std::panicking::default_hook         
             at src/libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook 
             at src/libstd/panicking.rs:491
   5: std::panicking::continue_panic_fmt   
             at src/libstd/panicking.rs:398                                           
   6: rust_begin_unwind                    
             at src/libstd/panicking.rs:325
   7: core::panicking::panic_fmt           
             at src/libcore/panicking.rs:95                                                                                                                                 
   8: core::panicking::panic               
             at src/libcore/panicking.rs:59
   9: <core::option::Option<T>>::unwrap
             at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libcore/macros.rs:20
  10: <regex_syntax::hir::translate::TranslatorI<'t, 'p> as regex_syntax::ast::visitor::Visitor>::visit_post
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.5/src/hir/translate.rs:339
  11: regex_syntax::ast::visitor::HeapVisitor::visit
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.5/src/ast/visitor.rs:261
  12: regex_syntax::ast::visitor::visit
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.5/src/ast/visitor.rs:130
  13: regex_syntax::hir::translate::Translator::translate
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.5/src/hir/translate.rs:143
  14: regex_syntax::parser::Parser::parse
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.5/src/parser.rs:203
@BurntSushi BurntSushi added the bug label Jan 28, 2019
BurntSushi added a commit that referenced this issue Mar 30, 2019
This fixes a bug where the HIR translator would panic on regexes such as
`(?i){1}` since it assumes that every repetition operator has a valid
sub-expression, and `(?i)` is not actually a sub-expression (but is more
like a directive instead).

Previously, we fixed this same bug for *uncounted* repetitions in commit
17764ff (for bug #465), but we did not fix it for counted repetitions.
We apply the same fix here.

Fixes #555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants