Skip to content

Commit

Permalink
Remove unsound quantifier reduction rules
Browse files Browse the repository at this point in the history
Some of the quantifier reduction rules in oniguruma are invalid, leading to new
regular expressions with different semantics. This commit removes two such
reduction rules.

https://bugs.ruby-lang.org/issues/17341
ruby/ruby#3808
  • Loading branch information
jirkamarsik committed Nov 24, 2020
1 parent 6b84cb3 commit 509a83d
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/org/joni/ast/QuantifierNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ static enum ReduceType {
AQ, /* to '*?' */
QQ, /* to '??' */
P_QQ, /* to '+)??' */
PQ_Q, /* to '+?)?' */
}

static final ReduceType[][]REDUCE_TABLE = {
Expand All @@ -146,7 +145,7 @@ static enum ReduceType {
{A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */
{DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */
{DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */
{ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */
{ASIS, ASIS, ASIS, AQ, AQ, DEL} /* '+?' */
};


Expand Down Expand Up @@ -193,16 +192,6 @@ public void reduceNestedQuantifier(QuantifierNode other) {
other.greedy = true;
return;

case PQ_Q:
setTarget(other);
lower = 0;
upper = 1;
greedy = true;
other.lower = 1;
other.upper = REPEAT_INFINITE;
other.greedy = false;
return;

case ASIS:
setTarget(other);
return;
Expand Down

0 comments on commit 509a83d

Please sign in to comment.