summaryrefslogtreecommitdiff
path: root/ext/pcre
diff options
context:
space:
mode:
authorMichael Moravec <mail@majkl578.cz>2017-10-10 19:00:29 +0200
committerNikita Popov <nikita.ppv@gmail.com>2017-12-16 17:34:41 +0100
commit84235344f96e11b88ed5a2060baed5532718a46f (patch)
tree94eb0d4c4316d03a0d934669eef3a6029a37adb8 /ext/pcre
parentabdece72c25e9728986fccfbc4329fe2cceb1c72 (diff)
downloadphp-git-84235344f96e11b88ed5a2060baed5532718a46f.tar.gz
Fixed bug #75355: preg_quote() does not quote # control character
Diffstat (limited to 'ext/pcre')
-rw-r--r--ext/pcre/php_pcre.c2
-rw-r--r--ext/pcre/tests/bug75355.phpt15
2 files changed, 17 insertions, 0 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 3b6f795a8c..47f22a57f8 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -2629,6 +2629,7 @@ static PHP_FUNCTION(preg_quote)
case '|':
case ':':
case '-':
+ case '#':
extra_len++;
break;
@@ -2678,6 +2679,7 @@ static PHP_FUNCTION(preg_quote)
case '|':
case ':':
case '-':
+ case '#':
*q++ = '\\';
*q++ = c;
break;
diff --git a/ext/pcre/tests/bug75355.phpt b/ext/pcre/tests/bug75355.phpt
new file mode 100644
index 0000000000..d37d781bc1
--- /dev/null
+++ b/ext/pcre/tests/bug75355.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #75355 (preg_quote() does not quote # control character)
+--FILE--
+<?php
+
+var_dump(preg_quote('#'));
+
+var_dump(preg_match('~^(' . preg_quote('hello#world', '~') . ')\z~x', 'hello#world', $m));
+
+var_dump($m[1]);
+?>
+--EXPECT--
+string(2) "\#"
+int(1)
+string(11) "hello#world"