summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pcre/php_pcre.c5
-rw-r--r--ext/pcre/tests/bug26927.phpt11
2 files changed, 16 insertions, 0 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 7e85410299..13c28b886d 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -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++ = '\\';
diff --git a/ext/pcre/tests/bug26927.phpt b/ext/pcre/tests/bug26927.phpt
new file mode 100644
index 0000000000..25b6b2e572
--- /dev/null
+++ b/ext/pcre/tests/bug26927.phpt
@@ -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"