Bug #72770 [Ana->Nab]: logical filter's trim is not trimming trailing spaces

From: Date: Sun, 07 Aug 2016 01:47:11 +0000
Subject: Bug #72770 [Ana->Nab]: logical filter's trim is not trimming trailing spaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203008@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: Analyzed +Status: Not a bug Type: Bug Package: Filter related Operating System: * PHP Version: Irrelevant Assigned To: yohgaki Block user comment: N Private report: N New Comment: Turned out strange behavior was not caused by this... Previous Comments: ------------------------------------------------------------------------ [2016-08-06 17:26:18] nikic@php.net I don't understand. The code you show trims both the left and right side of the string. What's wrong with it? Please provide a reproduce case. ------------------------------------------------------------------------ [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

« previous php.bugs (#203008) next »