Bug #72770 [Opn->Ana]: logical filter's trim is not trimming trailing spaces
| From: | yohgaki@php.net | Date: | Sat, 06 Aug 2016 04:57:35 +0000 |
| Subject: | Bug #72770 [Opn->Ana]: logical filter's trim is not trimming trailing spaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202991@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72770&edit=1
ID: 72770
Updated by: yohgaki@php.net
Reported by: yohgaki@php.net
Summary: logical filter's trim is not trimming trailing
spaces
-Status: Open
+Status: Analyzed
Type: Bug
Package: Filter related
Operating System: *
PHP Version: Irrelevant
-Assigned To:
+Assigned To: yohgaki
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2016-08-06 04:57:21] yohgaki@php.net
Description:
------------
logical_filters.c uses following macro in filter_private.h for trimming strings.
#define PHP_FILTER_TRIM_DEFAULT_EX(p, len, return_if_empty) { \
while ((len > 0) && (*p == ' ' || *p == '\t' || *p ==
'\r' || *p == '\v' || *p == '\n')) { \
p++; \
len--; \
} \
if (len < 1 && return_if_empty) { \
RETURN_VALIDATION_FAILED("Filter validated value became empty after trim", 0); \
} \
if (len > 0) { \
while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' ||
p[len-1] == '\v' || p[len-1] == '\n') { \
len--; \
} \
} \
}
As you can see by the code, trailing spaces are not trimmed, but it only shorten length by counting
spaces in it.
e.g. ' 1234 5678' would result in unwanted condition.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72770&edit=1