Bug #72770 [NEW]: logical filter's trim is not trimming trailing spaces
From: yohgaki
Operating system: *
PHP version: Irrelevant
Package: Filter related
Bug Type: Bug
Bug description:logical filter's trim is not trimming trailing spaces
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 bug report at https://bugs.php.net/bug.php?id=72770&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72770&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72770&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72770&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72770&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72770&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72770&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72770&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72770&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72770&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72770&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72770&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72770&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72770&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72770&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72770&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72770&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72770&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72770&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72770&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72770&r=mysqlcfg
Thread (4 messages)
- yohgaki@php.net