com php-src: Fix #69202: FILTER_FLAG_STRIP_BACKTICK ign ored unless other flags are used.: ext/filter/s anitizing_filters.c ext/filter/tests/bug69202
.phpt
| From: | Xinchen Hui | Date: | Mon, 09 Mar 2015 09:14:47 +0000 |
| Subject: | com php-src: Fix #69202: FILTER_FLAG_STRIP_BACKTICK ign ored unless other flags are used.: ext/filter/s anitizing_filters.c ext/filter/tests/bug69202 .phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85396@lists.php.net to get a copy of this message | ||
Commit: fdbdb1151457a59bc6598de4b98b12aa522b4134
Author: Jeff Welch <whatthejeff@gmail.com> Mon, 9 Mar 2015 03:54:19 -0400
Committer: Xinchen Hui <laruence@php.net> Mon, 9 Mar 2015 17:14:47 +0800
Parents: 2a2c74997dd754b27c5d890c0025001878318664
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fdbdb1151457a59bc6598de4b98b12aa522b4134
Log:
Fix #69202: FILTER_FLAG_STRIP_BACKTICK ignored unless other flags are used.
Bugs:
https://bugs.php.net/69202
Changed paths:
M ext/filter/sanitizing_filters.c
A ext/filter/tests/bug69202.phpt
Diff:
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index f786f29..43241cc 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -115,7 +115,7 @@ static void php_filter_strip(zval *value, zend_long flags)
zend_string *buf;
/* Optimization for if no strip flags are set */
- if (! ((flags & FILTER_FLAG_STRIP_LOW) || (flags & FILTER_FLAG_STRIP_HIGH)) ) {
+ if (!(flags & (FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK)))
{
return;
}
diff --git a/ext/filter/tests/bug69202.phpt b/ext/filter/tests/bug69202.phpt
new file mode 100644
index 0000000..9922986
--- /dev/null
+++ b/ext/filter/tests/bug69202.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #69202 (FILTER_FLAG_STRIP_BACKTICK ignored unless other flags are used)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var("`
abc`", FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_BACKTICK));
+var_dump(filter_var("`abc`", FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_BACKTICK));
+var_dump(filter_var("`abc`", FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK));
+var_dump(filter_var("`abc`", FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
+?>
+--EXPECT--
+string(3) "abc"
+string(3) "abc"
+string(3) "abc"
+string(9) "`abc`"