[pcre-dev] [Bug 1583] New: Substitution inserting extra char…

Top Page
Delete this message
Author: Michael Carino
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 1583] New: Substitution inserting extra character
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1583
           Summary: Substitution inserting extra character
           Product: PCRE
           Version: 10.00 (PCRE2)
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: carinom@???
                CC: pcre-dev@???



If a replacement string ends in a capturing group number without parentheses,
the last character is literally included at the end of the replacement string.
I have found this to occur with any number of capture groups, including 0 and
10+. It also seems to occur using any character width (8/16/32). If global
substitution is enabled, it will do it for each occurrence of the pattern.

The example below is ripped from pcre2test, however I can confirm that the bug
exists as part of the actual pcre2_substitute() function, as this is how I
originally discovered it.

E.g.
    re> /./replace=$0
    data> a
    1: a0


    re> /(.)(.)/replace=$2+$1
    data> abc
    1: b+a1c


    re> /(.)(.)/g,replace=$2$1
    data> abcdefgh
    4: ba1dc1fe1hg1



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