Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20843 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76977 invoked by uid 1010); 29 Nov 2005 16:43:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76962 invoked from network); 29 Nov 2005 16:43:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2005 16:43:48 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:52687] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 8A/D5-14828-3458C834 for ; Tue, 29 Nov 2005 11:43:48 -0500 Received: (qmail 8296 invoked from network); 29 Nov 2005 16:43:43 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 29 Nov 2005 16:43:43 -0000 Message-ID: <438C853D.8050608@zend.com> Date: Tue, 29 Nov 2005 19:43:41 +0300 User-Agent: Thunderbird 1.5 (X11/20051025) MIME-Version: 1.0 To: Gareth Ardron CC: internals@lists.php.net References: <438C7A4C.9090503@fission.org.uk> In-Reply-To: <438C7A4C.9090503@fission.org.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] is_int/is_numeric possible bug From: antony@zend.com (Antony Dovgal) ./sapi/cli/php -r 'var_dump(is_int("jkhdsjh"));' bool(false) ./sapi/cli/php -v PHP 5.1.2-dev (cli) What am I doing wrong? On 29.11.2005 18:57, Gareth Ardron wrote: > Hi. > > Think I've just stumbled upon a possible bug with is_int. > > if you've got the following code: > >
> > >
> if (!is_int($_REQUEST['days']) || $_REQUEST['days'] < 0) { > $_REQUEST['days'] = 10; > } > print "
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. > -- Wbr, Antony Dovgal