Re: is_int/is_numeric possible bug

From: Date: Tue, 29 Nov 2005 16:13:59 +0000
Subject: Re: is_int/is_numeric possible bug
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-20838@lists.php.net to get a copy of this message
Just out of curiosity, to which versions does this apply? Ron "Gareth Ardron" <gareth@fission.org.uk> schreef in bericht news:438C7A4C.9090503@fission.org.uk... > Hi. > > Think I've just stumbled upon a possible bug with is_int. > > if you've got the following code: > > <form action='1.php' method='post'> > <input type='text' name='days'> > <input type='submit' name='submit' value='submit'> > </form> > <?php > if (!is_int($_REQUEST['days']) || $_REQUEST['days'] < 0) { > $_REQUEST['days'] = 10; > } > print "<br>days::".$_REQUEST['days']; > ?> > > and somebody enters, say "jkhdsjh" into the form, is_int() returns 1, > thereby not setting the $_REQUEST['days'] variable to 10 - if I switch to > using is_numeric then everything works as it should. Obviously, this isn't > ideal as somebody could then enter 2.5 rather than the integers that I > want to be passed. > > Looking at the source, this is in ext/standard/type.c in the php_is_type() > function which seems to be messing up. > > Can anybody confirm this is: > a) undesired behaviour and I'm not just being very "special" and > b) that this is happening. I've tried on two boxes with 5.1.1[0] but it'd > help to get somebody else's opinion > > If it's a bug, I'll do a patch up later tonight - just want to get it > confirmed first. > > Cheers. > > -- > Gareth Ardron > > [0] both debian/linux boxes. One i386, one x86_64.

« previous php.internals (#20838) next »