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:08:35 +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-85393@lists.php.net to get a copy of this message | ||
Commit: 66a2c528fe29c1af2c98e67acaa4b900cd57496d
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:08:35 +0800
Parents: fa72f1ea869e23fd92c50f69a8350e50d57e1c12
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=66a2c528fe29c1af2c98e67acaa4b900cd57496d
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 157102f..975e425 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -113,7 +113,7 @@ static void php_filter_strip(zval *value, long flags)
int i, c;
/* 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`"