[pcre-dev] [Bug 779] New: Group inside a conditionnal patter…

Αρχική Σελίδα
Delete this message
Συντάκτης: Quentin Raynaud
Ημερομηνία:  
Προς: pcre-dev
Καινούρια Θέματα: [pcre-dev] [Bug 779] Group inside a conditionnal pattern may cause a failed match without any reason to
Αντικείμενο: [pcre-dev] [Bug 779] New: Group inside a conditionnal pattern may cause a failed match without any reason to
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=779
           Summary: Group inside a conditionnal pattern may cause a failed
                    match without any reason to
           Product: PCRE
           Version: 7.6
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: pcre@???
                CC: pcre-dev@???



Created an attachment (id=281)
--> (http://bugs.exim.org/attachment.cgi?id=281)
Test files

I was trying to write a regexp to find well formed group in PHP files. The
regexp appeared to fail on 2 specific files and I was not able to find the
reason for it. I tried to simplify the regexp a little and it is when I found
the following bug (or what I think is one). I don't know if it persists after
PCRE 7.6 since I don't have a newer version and won't have a good way to try it
even so.

In the attachment I give 3 files :
- test_file.txt: contains the file to match. Everything in it should match from
the first { to the last }.
- works.regexp: contains a regexp matching what it should
- fail.regexp: contains a regexp failing on the file

What is interessant is that the only modification in the regexp it is line 27
where [^\\']*?' (matching version) becomes (?:[^\\'])*?' (not mathcing
version). As you might see, the only difference between those two regexp is
merely a useless non-capturing block (it also fails with a capturing block). I
don't believe that the addition of those two parenthesis should cause a failing
match.

I found this using preg_match (PHP 5.2.6) on a Kubuntu 8.10 x64 up to date.

There is something that is bothering me : the same regexp appears to work fine
with Perl: I just had to change conditional patterns to have them looking like
(?(<name>) instead of (?(name).


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email