Fixed Bug #26927 (preg_quote() does not escape \0).

This commit is contained in:
Ilia Alshanetsky 2004-01-16 02:29:50 +00:00
parent c1ac285760
commit 0715651785
2 changed files with 16 additions and 0 deletions

View File

@ -1388,6 +1388,11 @@ PHP_FUNCTION(preg_quote)
*q++ = c;
break;
case '\0':
*q++ = '\\';
*q++ = '0';
break;
default:
if (quote_delim && c == delim_char)
*q++ = '\\';

View File

@ -0,0 +1,11 @@
--TEST--
Bug #26927 (preg_quote() does not escape \0)
--FILE--
<?php
$str = "a\000b";
$str_quoted = preg_quote($str);
var_dump(preg_match("!{$str_quoted}!", $str), $str_quoted);
?>
--EXPECT--
int(1)
string(4) "a\0b"