Debian Codegraph @

tests/pcre-invalid-utf8-input

raw
1 #! /bin/sh
2 # Ensure that grep -P doesn't abort or infloop for invalid multi-byte input
3 #
4 # Copyright (C) 2013-2025 Free Software Foundation, Inc.
5 #
6 # Copying and distribution of this file, with or without modification,
7 # are permitted in any medium without royalty provided the copyright
8 # notice and this notice are preserved.
9
10 . "${srcdir=.}/init.sh"; path_prepend_ ../src
11 require_timeout_
12 require_en_utf8_locale_
13 require_compiled_in_MB_support
14 LC_ALL=en_US.UTF-8 require_pcre_
15
16 fail=0
17
18 printf 'j\202j\nj\nk\202\n' > in || framework_failure_
19
20 LC_ALL=en_US.UTF-8 timeout 10 grep -P j in
21 test $? -eq 0 || fail=1
22
23 LC_ALL=en_US.UTF-8 timeout 10 grep -P 'k$' in
24 test $? -eq 1 || fail=1
25
26 echo k >exp
27
28 LC_ALL=en_US.UTF-8 timeout 10 grep -aoP 'k*' in >out || fail=1
29 compare exp out || fail=1
30
31 Exit $fail