ammar / regexp_parser

A regular expression parser library for Ruby
MIT License
144 stars 23 forks source link

Regexp accepted but rejected by regexp_parser #88

Closed mbj closed 1 year ago

mbj commented 1 year ago
irb(main):002:0> /(a)(?('01'))/
=> /(a)(?('01'))/
irb(main):003:0> Regexp::Parser.parse("(a)(?('01'))")
/home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/parser.rb:290:in `conditional': Unknown Conditional token condition_open (Regexp::Parser::UnknownTokenError)
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/parser.rb:81:in `parse_token'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/parser.rb:39:in `block in parse'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/lexer.rb:74:in `emit'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/lexer.rb:57:in `block in lex'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/scanner.rb:2422:in `emit'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/scanner.rb:2475:in `emit_literal'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/scanner.rb:2408:in `emit'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/scanner.rb:2172:in `scan'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/scanner.rb:21:in `scan'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/lexer.rb:33:in `lex'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/lexer.rb:17:in `lex'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/parser.rb:38:in `parse'
    from /home/mutant-dev/.gem/ruby/3.2.2/gems/regexp_parser-2.8.2/lib/regexp_parser/parser.rb:22:in `parse'
    from (irb):3:in `<main>'
    from /home/mutant-dev/.rubies/ruby-3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
    from /home/mutant-dev/.rubies/ruby-3.2.2/bin/irb:25:in `load`

I've reduced this from another rubyspec corpus case.

jaynetics commented 1 year ago

@mbj

thanks again! do you have any more? otherwise i'll cut a new release with a fix for this one.

mbj commented 1 year ago

@jaynetics maybe, I only reported the first crash in that file mutant corpus test failed on, have to update to your branch and re-run.