com php-src: Fix #69203: FILTER_FLAG_STRIP_HIGH doesn 't strip ASCII 127: NEWS ext/filter/sanitiz ing_filters.c ext/filter/tests/bug69203.phpt
| From: | Nikita Popov | Date: | Sat, 14 Mar 2015 08:17:36 +0000 |
| Subject: | com php-src: Fix #69203: FILTER_FLAG_STRIP_HIGH doesn 't strip ASCII 127: NEWS ext/filter/sanitiz ing_filters.c ext/filter/tests/bug69203.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85516@lists.php.net to get a copy of this message | ||
Commit: 1e51c5411e2d1bdcddb6731a502ce429605c1d08
Author: Jeff Welch <whatthejeff@gmail.com> Mon, 9 Mar 2015 07:14:22 -0400
Committer: Nikita Popov <nikic@php.net> Sat, 14 Mar 2015 09:17:36 +0100
Parents: 5b87d5204108f78d433880b12b941ba8fba10e62
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1e51c5411e2d1bdcddb6731a502ce429605c1d08
Log:
Fix #69203: FILTER_FLAG_STRIP_HIGH doesn't strip ASCII 127
Bugs:
https://bugs.php.net/69203
Changed paths:
M NEWS
M ext/filter/sanitizing_filters..c
A ext/filter/tests/bug69203.phpt
Diff:
diff --git a/NEWS b/NEWS
index 5e1a68a..46a1102 100644
--- a/NEWS
+++ b/NEWS
@@ -14,8 +14,10 @@ PHP NEWS
with an Iterator). (Nikita)
- Filter:
- . Fixed bug #69202: (FILTER_FLAG_STRIP_BACKTICK ignored unless other
+ . Fixed bug #69202 (FILTER_FLAG_STRIP_BACKTICK ignored unless other
flags are used). (Jeff Welch)
+ . Fixed bug #69203 (FILTER_FLAG_STRIP_HIGH doesn't strip ASCII 127). (Jeff
+ Welch)
- Mbstring:
. Fixed bug #68846 (False detection of CJK Unified Ideographs Extension E).
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters..c
index 975e425..56ac207 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -121,7 +121,7 @@ static void php_filter_strip(zval *value, long flags)
buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
c = 0;
for (i = 0; i < Z_STRLEN_P(value); i++) {
- if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
+ if ((str[i] >= 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
} else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
} else if ((str[i] == '`') && (flags & FILTER_FLAG_STRIP_BACKTICK)) {
} else {
diff --git a/ext/filter/tests/bug69203.phpt b/ext/filter/tests/bug69203.phpt
new file mode 100644
index 0000000..4bafe33
--- /dev/null
+++ b/ext/filter/tests/bug69203.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #69203 (FILTER_FLAG_STRIP_HIGH doesn't strip ASCII 127)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var("\x7f", FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH));
+var_dump(filter_var("\x7f", FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH));
+var_dump(filter_var("\x7f", FILTER_SANITIZE_ENCODED, FILTER_FLAG_STRIP_HIGH));
+var_dump(filter_var("\x7f", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_HIGH));
+?>
+--EXPECT--
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""