]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix enforcement of restrictions inside regexp lookaround constraints.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 7 Nov 2015 17:43:24 +0000 (12:43 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 7 Nov 2015 17:43:24 +0000 (12:43 -0500)
commitbfb10db81ec9f4d2cb8de20c6af03463f89154c9
tree69b456d6f948536edb2aaccc1ca9efc7d5e2ea81
parentcaff7fc3fb1184d0fe39228cd8922e664006105b
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.
src/backend/regex/regcomp.c
src/test/regress/expected/regex.out
src/test/regress/sql/regex.sql