php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71577 filter_var / FILTER_SANITIZE_FULL_SPECIAL_CHARS differs from htmlspecialchars
Submitted: 2016-02-12 16:08 UTC Modified: -
From: stheine at arcor dot de Assigned:
Status: Open Package: Filter related
PHP Version: 5.6.18 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stheine at arcor dot de
New email:
PHP Version: OS:

 

 [2016-02-12 16:08 UTC] stheine at arcor dot de
Description:
------------
documentation ( http://php.net/manual/en/filter.filters.sanitize.php ) states:

filter_var, option FILTER_SANITIZE_FULL_SPECIAL_CHARS: Equivalent to calling htmlspecialchars() with ENT_QUOTES set.
but in reality, the two differ.

the FILTER_SANITIZE_FULL_SPECIAL_CHARS is missing the FILTER_FLAG_ENCODE_AMP flag (which is not even documented for that filter) to actually be equivalent to htmlspecialchars() as documented.

Test script:
---------------
$STRING = "1 2";
echo htmlspecialchars($STRING, ENT_QUOTES)."\n".
     filter_var($STRING, FILTER_SANITIZE_FULL_SPECIAL_CHARS)."\n";

1 2
1 2

Expected result:
----------------
following the documentation, I expect 

filter_var("1 2", FILTER_SANITIZE_FULL_SPECIAL_CHARS)

to return

1 2

Actual result:
--------------
1 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 16 04:01:27 2019 UTC