php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50389 filter_var with FILTER_SANITIZE_STRING misses ` character
Submitted: 2009-12-04 17:43 UTC Modified: 2009-12-07 13:44 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: aldekein at myevil dot info Assigned:
Status: Closed Package: Filter related
PHP Version: 5.2.11 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 7 = ?
Subscribe to this entry?

 
 [2009-12-04 17:43 UTC] aldekein at myevil dot info
Description:
------------
I try to sanitize:
Bug: "'`

I get:
Bug: \"\'`

The ` character is not sanitized. Why?

Reproduce code:
---------------
echo filter_var("\"'`", FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);

or

echo filter_var("\"'`", FILTER_SANITIZE_STRING);

Expected result:
----------------
\"\'\�

00 = code for ` character.

Actual result:
--------------
\"\'`

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-07 08:06 UTC] jani@php.net
Oh, it was backquote, didn't paste well. :) Anyway, why should that be stripped..? Or why it should end up as null..? 
 [2009-12-07 09:36 UTC] aldekein at myevil dot info
This filter removes data that is potentially harmful for the application. I expected to get a clear string that could be used in MySQL, for example. But the backquote is dangerous in MySQL statements.
 [2009-12-07 13:44 UTC] iliaa@php.net
The FILTER_FLAG_STRIP_HIGH flag only strips chars with value > 127, ` 
(backtick) is 96, so it does not get stripped.

I've added FILTER_FLAG_STRIP_BACKTICK filter for PHP 5.3+ that will 
allow removal of the backtick character.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC