# PHP 5.1

- Thread: https://externals.io/message/14527
- Original archive: https://news-web.php.net/php.internals/14527
- Started by Binam on 2005-02-02T17:23:41+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14527 — Binam — 2005-02-02T17:23:41+00:00

URL: https://externals.io/message/14527#14527

I know that my opinion probably means diddly but my %2 is free. ;)

If I am understanding all of this right, if the raw varible contains
some shell code like "\x90\x90\x90\xab\xa3\x54\x77" and I do something
like $var = filter(GET,'foo',FILTER_NUMBER); $var would contain
something like " 90 90 90 3 54 77". That still isn't valid, I filtered
it for a number because that's what I am expecting. Valid values would
be something like "12345" or "123.456".

There are some cases where a filter would be nice. Like for a textarea
where a user might insert some HTML, <script> tags, etc. You could strip
out the tags, and accept the rest.

But if I am expecting a field to contain a number I am going to be
looking for an int or a float. If I am expecting a phone number I would
look for something that has a max length, a min length, must contain
numbers, and only limited set of alpha characters (-,+,.,<SP>).

I want to know `TRUE` or `FALSE` does this varible contain what I am expect
it to. If `FALSE` I don't care what *is* there, as far as I'm concerned it
isn't valid. I probably can't trust it even if it is "filtered". I am
going to return some kind of error, and request that they reenter the
data.

Jess


-----Original Message-----
From: Rasmus Lerdorf [mailto:rasmus@lerdorf.com] 
Sent: Tuesday, February 01, 2005 5:55 PM
To: Nick Loeve
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] PHP 5.1

Nick Loeve wrote:
> 
> > […]
> Isn't that something you can use mod_security for? I don't know of the

> availability of that module on a standard host, but on a dedicated 
> server you could install it.

No, because we don't actually want to lose the raw data.  We need to
save the raw data internally in PHP and make it available via the filter
function.  So if a strict default ini filter is enabled you would have
something like this:

   GET /script.php?foo=<xss hack>123 Hello</xss hack>

   echo $_GET['foo'];

Would output:  123 Hello

   echo filter(GET,'foo',FILTER_RAW);

Would output: <xss hack>123 Hello</xss hack>

   echo filter(GET,'foo',FILTER_NUMBER);
 
Would output:  123

The extra spaces are intentional.  Stripped characters are replaced with
a single space.  So if you had: abc<font size=10>def You would end up
with: abc def

-Rasmus

--
 To unsubscribe,
visit: http://www.php.net/unsub.php
