Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5a66e7

Browse filesBrowse files
committed
Fix another ancient bug in parsing of BRE-mode regular expressions.
While poking at the regex code, I happened to notice that the bug squashed in commit afcc877 had a sibling: next() failed to return a specific value associated with the '}' token for a "\{m,n\}" quantifier when parsing in basic RE mode. Again, this could result in treating the quantifier as non-greedy, which it never should be in basic mode. For that to happen, the last character before "\}" that sets "nextvalue" would have to set it to zero, or it'd have to have accidentally been zero from the start. The failure can be provoked repeatably with, for example, a bound ending in digit "0". Like the previous patch, back-patch all the way.
1 parent 614b7f1 commit b5a66e7
Copy full SHA for b5a66e7

File tree

Expand file treeCollapse file tree

3 files changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-3
lines changed

‎src/backend/regex/regc_lex.c

Copy file name to clipboardExpand all lines: src/backend/regex/regc_lex.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ next(struct vars *v)
389389
{
390390
v->now++;
391391
INTOCON(L_BRE);
392-
RET('}');
392+
RETV('}', 1);
393393
}
394394
else
395395
FAILW(REG_BADBR);

‎src/test/modules/test_regex/expected/test_regex.out

Copy file name to clipboardExpand all lines: src/test/modules/test_regex/expected/test_regex.out
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,21 @@ ERROR: invalid regular expression: quantifier operand invalid
614614
-- expectError 7.15 - a*+ BADRPT
615615
select * from test_regex('a*+', '', '-');
616616
ERROR: invalid regular expression: quantifier operand invalid
617-
-- test for ancient brenext() bug; not currently in Tcl
617+
-- tests for ancient brenext() bugs; not currently in Tcl
618618
select * from test_regex('.*b', 'aaabbb', 'b');
619619
test_regex
620620
------------
621621
{0}
622622
{aaabbb}
623623
(2 rows)
624624

625+
select * from test_regex('.\{1,10\}', 'abcdef', 'bQ');
626+
test_regex
627+
-----------------
628+
{0,REG_UBOUNDS}
629+
{abcdef}
630+
(2 rows)
631+
625632
-- doing 8 "braces"
626633
-- expectMatch 8.1 NQ "a{0,1}" "" ""
627634
select * from test_regex('a{0,1}', '', 'NQ');

‎src/test/modules/test_regex/sql/test_regex.sql

Copy file name to clipboardExpand all lines: src/test/modules/test_regex/sql/test_regex.sql
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ select * from test_regex('a?*', '', '-');
214214
select * from test_regex('a+*', '', '-');
215215
-- expectError 7.15 - a*+ BADRPT
216216
select * from test_regex('a*+', '', '-');
217-
-- test for ancient brenext() bug; not currently in Tcl
217+
-- tests for ancient brenext() bugs; not currently in Tcl
218218
select * from test_regex('.*b', 'aaabbb', 'b');
219+
select * from test_regex('.\{1,10\}', 'abcdef', 'bQ');
219220

220221
-- doing 8 "braces"
221222

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.