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