@@ -57,7 +57,12 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data'
5757 printf "\\200\\n" >invalid-0x80 &&
5858 echo "ævar" >expected &&
5959 cat expected >>invalid-0x80 &&
60- git add invalid-0x80
60+ git add invalid-0x80 &&
61+
62+ # Test for PCRE2_MATCH_INVALID_UTF bug
63+ # https://bugs.exim.org/show_bug.cgi?id=2642
64+ printf "\\345Aæ\\n" >invalid-0xe5 &&
65+ git add invalid-0xe5
6166'
6267
6368test_expect_success GETTEXT_LOCALE,LIBPCRE2 ' PCRE v2: grep ASCII from invalid UTF-8 data' '
@@ -67,21 +72,55 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UT
6772 test_cmp expected actual
6873'
6974
75+ test_expect_success GETTEXT_LOCALE,LIBPCRE2 ' PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
76+ git grep -h "Aæ" invalid-0xe5 >actual &&
77+ test_cmp invalid-0xe5 actual &&
78+ git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
79+ test_cmp invalid-0xe5 actual
80+ '
81+
7082test_expect_success GETTEXT_LOCALE,LIBPCRE2 ' PCRE v2: grep non-ASCII from invalid UTF-8 data' '
7183 git grep -h "æ" invalid-0x80 >actual &&
7284 test_cmp expected actual &&
7385 git grep -h "(*NO_JIT)æ" invalid-0x80 >actual &&
7486 test_cmp expected actual
7587'
7688
89+ test_expect_success GETTEXT_LOCALE,LIBPCRE2 ' PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
90+ git grep -h "Aæ" invalid-0xe5 >actual &&
91+ test_cmp invalid-0xe5 actual &&
92+ git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
93+ test_cmp invalid-0xe5 actual
94+ '
95+
96+ test_lazy_prereq PCRE2_MATCH_INVALID_UTF '
97+ test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF
98+ '
99+
77100test_expect_success GETTEXT_LOCALE,LIBPCRE2 ' PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
78101 test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
79- if test -s actual
80- then
81- test_cmp expected actual
82- fi &&
83- test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
84- ! test_cmp expected actual
102+ test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual
103+ '
104+
105+ test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF ' PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
106+ git grep -hi "Æ" invalid-0x80 >actual &&
107+ test_cmp expected actual &&
108+ git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
109+ test_cmp expected actual
110+ '
111+
112+ test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF ' PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' '
113+ git grep -hi "Æ" invalid-0xe5 >actual &&
114+ test_cmp invalid-0xe5 actual &&
115+ git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual &&
116+ test_cmp invalid-0xe5 actual &&
117+
118+ # Only the case of grepping the ASCII part in a way that
119+ # relies on -i fails
120+ git grep -hi "aÆ" invalid-0xe5 >actual &&
121+ test_cmp invalid-0xe5 actual &&
122+ git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual &&
123+ test_cmp invalid-0xe5 actual
85124'
86125
87126test_done
0 commit comments