Menu

#3937 Search with Non-Capturing Regexps and Literal Parents Breaks in 5.3

closed-fixed
None
5
2015-11-28
2015-11-02
Jesse Pavel
No

Revision 24042 made changes in PatternSearchMatcher.java to strip out non-capturing regexps in certain conditions, but the code doesn't work if the pattern searched for includes escaped literal parentheses.

For instance, this regexp

(?: \([\$\d\.]+\))? \(..\) *$

doesn't work in 5.3 (just search a blank buffer using it) because the method removeNonCapturingGroups() doesn't take into account the escaped "\)"

Discussion

  • Jesse Pavel

    Jesse Pavel - 2015-11-02
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,6 +2,8 @@
    
     For instance, this regexp
    
    +~~~~
     (?: \([\$\d\.]+\))? \(..\) *$
    +~~~~
    
    -doesn't work in 5.3 (just search a blank buffer using it) because the method removeNonCapturingGroups() doesn't take into account the escaped "\)".
    +doesn't work in 5.3 (just search a blank buffer using it) because the method removeNonCapturingGroups() doesn't take into account the escaped "\\)"
    
     
  • Dale Anson

    Dale Anson - 2015-11-03
    • assigned_to: Dale Anson
     
  • Dale Anson

    Dale Anson - 2015-11-04
    • status: open --> closed-fixed
     
  • Dale Anson

    Dale Anson - 2015-11-04

    Fixed in revision 24138.

     
  • Jesse Pavel

    Jesse Pavel - 2015-11-20

    The initial problem is fixed, thanks -- but there's another issue with removeNonCapturingGroups().

    To replicate a StringIndexOutOfBoundsException bug:

    Create a buffer with this line in it:

    1. 200 x HC393 (SN74HC393N) at $0.209 each
    

    search for this regular expression:

    (?:\d+\.)?\s*(\d+) ?x ?(.*) (?:\((.*)\))? (?:at|for)
    

    and attempt to replace it with this substitution:

    Amount: $1, Name: "$2", Num: "$3"
    

    and you'll trigger the exception.

    [This is using the daily builds of 5.3.1]

     
  • Dale Anson

    Dale Anson - 2015-11-28

    Thanks for testing this, I've added some bounds checking in revision 24166, which appears to fix the problem, that is, unless you find some other regex that breaks it.

     

Log in to post a comment.