xref: /PHP-7.2/ext/mbstring/tests/bug43301.phpt (revision 0dbb581c)
1--TEST--
2Bug #43301 (mb_ereg*_replace() crashes when replacement string is invalid PHP expression and 'e' option is used)
3--SKIPIF--
4<?php
5if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
6if (!function_exists('mb_ereg_replace')) die('skip mb_ereg_replace() not available');
7?>
8--FILE--
9<?php
10
11$ptr = 'hello';
12
13$txt = <<<doc
14hello, I have got a cr*sh on you
15doc;
16
17echo mb_ereg_replace($ptr,'$1',$txt,'e');
18
19?>
20--EXPECTF--
21Deprecated: mb_ereg_replace(): The 'e' option is deprecated, use mb_ereg_replace_callback instead in %s%ebug43301.php on line %d
22
23Fatal error: Uncaught ParseError: syntax error, unexpected '1' (T_LNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in %sbug43301.php(%d) : mbregex replace:1
24Stack trace:
25#0 %sbug43301.php(%d): mb_ereg_replace('hello', '$1', 'hello, I have g...', 'e')
26#1 {main}
27
28Next Error: Failed evaluating code:
29$1 in %sbug43301.php:%d
30Stack trace:
31#0 %sbug43301.php(%d): mb_ereg_replace('hello', '$1', 'hello, I have g...', 'e')
32#1 {main}
33  thrown in %sbug43301.php on line %d
34