note 77042 added to ref.filter
| From: | fumble1 at web dot de | Date: | Sun, 12 Aug 2007 17:54:36 +0000 |
| Subject: | note 77042 added to ref.filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129425@lists.php.net to get a copy of this message | ||
I recommend you to use the FILTER_REQUIRE_SCALAR (or FILTER_REQUIRE_ARRAY) flags, since you can use
array-brackets both to access string offsets and array-element -- however, not only this can lead to
unexpected behaviour. Look at this example:
<?php
$image = basename(filter_input(INPUT_GET, 'src', FILTER_UNSAFE_RAW,
FILTER_FLAG_STRIP_LOW));
// further checks
?>
/script.php?src[0]=foobar will cause a warning. :-(
Hence my recommendation:
<?php
$image = basename(filter_input(INPUT_GET, 'src', FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR
| FILTER_FLAG_STRIP_LOW));
// further checks
?>
----
Server IP: 217.13.201.10
Probable Submitter: 172.158.38.223
----
Manual Page -- http://www.php.net/manual/en/ref.filter.php
Edit -- https://master.php.net/note/edit/77042
Del: integrated -- https://master.php.net/note/delete/77042/integrated
Del: useless -- https://master.php.net/note/delete/77042/useless
Del: bad code -- https://master.php.net/note/delete/77042/bad+code
Del: spam -- https://master.php.net/note/delete/77042/spam
Del: non-english -- https://master.php.net/note/delete/77042/non-english
Del: in docs -- https://master.php.net/note/delete/77042/in+docs
Del: other reasons-- https://master.php.net/note/delete/77042
Reject -- https://master.php.net/note/reject/77042
Search -- https://master.php.net/manage/user-notes.php