summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2022-07-25 16:35:23 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2022-07-25 16:35:23 +0000
commit6629948adcda40f2d1bb92812e578c2bfa590977 (patch)
treec770f15426367e0ac0612d86484039f983d15070
parent68a6628ffadddf08cb5374e8f71047bdaafcabe6 (diff)
parenta2b5b9e906256f43b0bac702424613ea0e7ddcb0 (diff)
downloadglib-6629948adcda40f2d1bb92812e578c2bfa590977.tar.gz
Merge branch 'rybalkin-gregex-remove-match-context-limits' into 'main'
gregex: do not set match and recursion limits on match context Closes #2700 See merge request GNOME/glib!2838
-rw-r--r--glib/gregex.c2
-rw-r--r--glib/tests/regex.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/glib/gregex.c b/glib/gregex.c
index 6741d2479..dd61dc481 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -769,8 +769,6 @@ match_info_new (const GRegex *regex,
&match_info->n_subpatterns);
match_info->match_context = pcre2_match_context_create (NULL);
- pcre2_set_match_limit (match_info->match_context, 65536); /* should be plenty */
- pcre2_set_recursion_limit (match_info->match_context, 64); /* should be plenty */
if (is_dfa)
{
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index bb1a5ff76..acb082b70 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2493,6 +2493,10 @@ main (int argc, char *argv[])
TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "dž", -1, 0, 0, TRUE);
TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, TRUE);
+ /* see https://gitlab.gnome.org/GNOME/glib/-/issues/2700 */
+ TEST_MATCH("(\n.+)+", G_REGEX_DEFAULT, 0, "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n", -1, 0, 0, TRUE);
+ TEST_MATCH("\n([\\-\\.a-zA-Z]+[\\-\\.0-9]*) +connected ([^(\n ]*)[^\n]*((\n +[0-9]+x[0-9]+[^\n]+)+)", G_REGEX_DEFAULT, 0, "Screen 0: minimum 1 x 1, current 3840 x 1080, maximum 8192 x 8192\nVirtual1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm\n 1920x1080 60.00*+ 59.96 \n 3840x2400 59.97 \n 3840x2160 59.97 \n 2880x1800 59.95 \n 2560x1600 59.99 \n 2560x1440 59.95 \n 1920x1440 60.00 \n 1856x1392 60.00 \n 1792x1344 60.00 \n 1920x1200 59.88 \n 1600x1200 60.00 \n 1680x1050 59.95 \n 1400x1050 59.98 \n 1280x1024 60.02 \n 1440x900 59.89 \n 1280x960 60.00 \n 1360x768 60.02 \n 1280x800 59.81 \n 1152x864 75.00 \n 1280x768 59.87 \n 1280x720 59.86 \n 1024x768 60.00 \n 800x600 60.32 \n 640x480 59.94 \nVirtual2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm\n 1920x1080 60.00*+ 59.96 \n 3840x2400 59.97 \n 3840x2160 59.97 \n 2880x1800 59.95 \n 2560x1600 59.99 \n 2560x1440 59.95 \n 1920x1440 60.00 \n 1856x1392 60.00 \n 1792x1344 60.00 \n 1920x1200 59.88 \n 1600x1200 60.00 \n 1680x1050 59.95 \n 1400x1050 59.98 \n 1280x1024 60.02 \n 1440x900 59.89 \n 1280x960 60.00 \n 1360x768 60.02 \n 1280x800 59.81 \n 1152x864 75.00 \n 1280x768 59.87 \n 1280x720 59.86 \n 1024x768 60.00 \n 800x600 60.32 \n 640x480 59.94 \nVirtual3 disconnected (normal left inverted right x axis y axis)\nVirtual4 disconnected (normal left inverted right x axis y axis)\nVirtual5 disconnected (normal left inverted right x axis y axis)\nVirtual6 disconnected (normal left inverted right x axis y axis)\nVirtual7 disconnected (normal left inverted right x axis y axis)\nVirtual8 disconnected (normal left inverted right x axis y axis)\n", -1, 0, 0, TRUE);
+
/* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
TEST_MATCH_NEXT0("a", "x", -1, 0);
TEST_MATCH_NEXT0("a", "ax", -1, 1);