bugfindutils - Bugs: bug #31330, Possible RegEx bug in locate

 
 

bug #31330: Possible RegEx bug in locate

Submitter:  None
Submitted:  Thu 14 Oct 2010 02:04:15 PM UTC
   
 
Category:  locate Severity:  3 - Normal
Item Group:  Wrong result Status:  Invalid
Privacy:  Public Assigned to:  jay
Originator Name:  John Muir Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.5.9
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 25 Oct 2010 07:51:06 AM UTC, comment #3: 

Thank you for the explanation.

It seems that one must escape the backslash. This worked as I expected

locate -ir .*/c/wrk/.*/src.*/grep\\..*$

locate -ir .<star>/c/wrk/.<star>/src.<star>/grep\\..<star>$

John Muir <john>
Fri 15 Oct 2010 09:29:17 PM UTC, comment #2: 

I'm afraid you are mistaken, as you have not correctly protected the arguments you're passing from interpretation by the shell.  This point is demonstrated by the attached script which shows the same problem applying to an invocation of grep.

Essentially what's happening is that \. is interpreted by the shell as an escaped . (despite the fact that . is not special to the shell).   Hence you're passing ..*$ to the locate program.   ..*$ matches any string at least one character long.



(file #21685)

James Youngman <jay>
Group administrator
Thu 14 Oct 2010 02:23:53 PM UTC, comment #1: 

For some reason in the description of the bug all the stars were removed when I submitted the entry (the email is OK).

The regex is

locate -ir .<star>/c/wrk/.<star>/src.<star>/grep\..<star>$

Anonymous
Thu 14 Oct 2010 02:04:15 PM UTC, original submission:  

I may be mistaken, but surely the last two hits don't satisfy the regular expression?

locate -ir .*/c/wrk/.*/src.*/grep\..*$
/cygdrive/c/c/wrk/Grep/src/Grep.java
/cygdrive/c/c/wrk/Grep/src/GrepSimplePattern.java
/cygdrive/c/c/wrk/Grep/src/GrepVisitor.java

(cut 'n' pasted from a Cygwin window)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #21685:  sv-31330.sh added by jay (189B - application/x-shellscript - Demonstration)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by john (Posted a comment)
  • -email is unavailable- added by jay (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-10-25 jay Open/ClosedOpen Closed
    2010-10-15 jay Attached File- Added sv-31330.sh, #21685
        StatusNone Invalid
        Assigned toNone jay

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code