Fixed bug where escaped parentheses in lookarounds were counted as regular parentheses instead of literals
This commit is contained in:
@@ -410,10 +410,10 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
if i >= len(re_runes) {
|
||||
return nil, fmt.Errorf("unclosed lookaround")
|
||||
}
|
||||
if re_runes[i] == '(' || re_runes[i] == nonCapLparenRune {
|
||||
if (re_runes[i] == '(' && re_runes[i-1] != '\\') || re_runes[i] == nonCapLparenRune {
|
||||
numOpenParens++
|
||||
}
|
||||
if re_runes[i] == ')' {
|
||||
if re_runes[i] == ')' && re_runes[i-1] != '\\' {
|
||||
numOpenParens--
|
||||
if numOpenParens == 0 {
|
||||
break
|
||||
@@ -589,10 +589,10 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
if i >= len(re_postfix) {
|
||||
return nil, fmt.Errorf("unclosed lookaround")
|
||||
}
|
||||
if re_postfix[i] == '(' || re_postfix[i] == nonCapLparenRune {
|
||||
if (re_postfix[i] == '(' && re_postfix[i-1] != '\\') || re_postfix[i] == nonCapLparenRune {
|
||||
numOpenParens++
|
||||
}
|
||||
if re_postfix[i] == ')' {
|
||||
if re_postfix[i] == ')' && re_postfix[i-1] != '\\' {
|
||||
numOpenParens--
|
||||
if numOpenParens == 0 {
|
||||
break
|
||||
|
Reference in New Issue
Block a user