pgsql: Fix enforcement of restrictions inside regexp lookaround constra

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix enforcement of restrictions inside regexp lookaround constra
Date: 2015-11-07 17:43:49
Message-ID: E1Zv7Wn-0000a3-Jl@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix enforcement of restrictions inside regexp lookaround constraints.

Lookahead and lookbehind constraints aren't allowed to contain backrefs,
and parentheses within them are always considered non-capturing. Or so
says the manual. But the regexp parser forgot about these rules once
inside a parenthesized subexpression, so that constructs like (\w)(?=(\1))
were accepted (but then not correctly executed --- a case like this acted
like (\w)(?=\w), without any enforcement that the two \w's match the same
text). And in (?=((foo))) the innermost parentheses would be counted as
capturing parentheses, though no text would ever be captured for them.

To fix, properly pass down the "type" argument to the recursive invocation
of parse().

Back-patch to all supported branches; it was agreed that silent
misexecution of such patterns is worse than throwing an error, even though
new errors in minor releases are generally not desirable.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/bfb10db81ec9f4d2cb8de20c6af03463f89154c9

Modified Files
--------------
src/backend/regex/regcomp.c | 2 +-
src/test/regress/expected/regex.out | 5 +++++
src/test/regress/sql/regex.sql | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Kevin Grittner 2015-11-07 18:26:34 Re: pgsql: Modify tqueue infrastructure to support transient record types.
Previous Message Peter Eisentraut 2015-11-07 14:38:30 Re: pgsql: Try to convince gcc that TupleQueueRemap never falls off the end