#49219 [Bgs]: Incorrect Inputvalidation on GET/POST/REQUEST params in function empty()

From: Date: Tue, 11 Aug 2009 09:25:44 +0000
Subject: #49219 [Bgs]: Incorrect Inputvalidation on GET/POST/REQUEST params in function empty()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140904@lists.php.net to get a copy of this message
 ID:               49219
 Updated by:       jani@php.net
 Reported By:      er at master-studios dot net
 Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: Centos
 PHP Version:      5.2.10
 New Comment:

And as for ?s[]=, that is not empty, it has one empty item:

# QUERY_STRING=foo[]= SCRIPT_FILENAME=t.php
src/build/php_5_2/sapi/cgi/php-cgi 
X-Powered-By: PHP/5.2.11-dev
Content-type: text/html

array(1) {
  ["foo"]=>
  array(1) {
    [0]=>
    string(0) ""
  }
}



Previous Comments:
------------------------------------------------------------------------

[2009-08-11 09:20:06] jani@php.net

# php -r '$foo=array();var_dump(empty($foo));'
bool(true)

Empty array is empty. Not a bug.

------------------------------------------------------------------------

[2009-08-11 08:38:00] er at master-studios dot net

Description:
------------
empty() function works incorrect for value validation

Reproduce code:
---------------
---
From manual page: function.empty
---

file.php:

<?php
  if(empty($_GET[s]))
     echo "EMPTY";
  else
     echo "FULL";
?>



Expected result:
----------------
on running the "file.php?s=asdf" works fine. 

Actual result:
--------------
And if an empty array is passed to this function there should also be a
"EMPTY" result. but if you call "file.php?s[]=" the you get a FULL.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49219&edit=1



Thread (3 messages)

« previous php.bugs (#140904) next »