Bug #70298 [NEW]: filter_var strips '/' characters, counter to docs
| From: | rfredlund13 at gmail dot com | Date: | Wed, 19 Aug 2015 02:36:01 +0000 |
| Subject: | Bug #70298 [NEW]: filter_var strips '/' characters, counter to docs | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-195319@lists.php.net to get a copy of this message | ||
From: rfredlund13 at gmail dot com
Operating system: Irrelevant
PHP version: 5.6.12
Package: Filter related
Bug Type: Bug
Bug description:filter_var strips '/' characters, counter to docs
Description:
------------
I was writing unit tests (using PHPUnit) to validate my email validation
functionality, which simply returned the result of filter_var($var,
FILTER_SANITIZE_EMAIL). I tested all of the characters allowed in the
documentation, but the / character was stripped out. I expected / to be
a valid character. This is what the documentation states:
FILTER_SANITIZE_EMAIL | Remove all characters except letters, digits and
!#$%&'*+-/=?^_`{|}~@.[].
Found at http://php.net/manual/en/filter.filters.sanitize.php
I then verified that this problem exists in the latest windows version
as well (ran from command line with -r flag).
This is either a problem with the implementation of the function, or
inaccurate documentation. I briefly tried to interpret RFC 5321/RFC5322,
but couldn't find this particular case.
Test script:
---------------
<?php
echo "Output: " . filter_var('!#$%&\'*+-=?^_`{|}~@.[]',
FILTER_SANITIZE_EMAIL);
echo "\nOutput: " . filter_var('!#$%&\'*+-=?^_`{|}~@.[]/',
FILTER_SANITIZE_EMAIL);
echo "\nOutput: " . filter_var('/', FILTER_SANITIZE_EMAIL);
?>
Expected result:
----------------
Output: !#$%&'*+-=?^_`{|}~@.[]
Output: !#$%&'*+-=?^_`{|}~@.[]/
Output: /
Actual result:
--------------
Output: !#$%&'*+-=?^_`{|}~@.[]
Output: !#$%&'*+-=?^_`{|}~@.[]
Output:
--
Edit bug report at https://bugs.php.net/bug.php?id=70298&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70298&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70298&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70298&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70298&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70298&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70298&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70298&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70298&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70298&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70298&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70298&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70298&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70298&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70298&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70298&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70298&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70298&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70298&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70298&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70298&r=mysqlcfg