Edit report at http://pear.php.net/bugs/bug.php?id=17662&edit=1
ID: 17662
Updated by: mj@php.net
Reported By: hm2k at php dot net
Summary: Is there really need for a regex or does a PHP
function do the trick?
-Status: Assigned
+Status: Wont fix
Type: Feature/Change Request
Package: Net_CheckIP
Package Version: SVN
PHP Version: Irrelevant
Assigned To: mj
Roadmap Versions:
New Comment:
-Status: Assigned
+Status: Wont fix
Using is_int() is not right here because it only works if the given
variable is acutally of type int already:
<?php
var_dump(is_int("123"));
var_dump(is_int(123));
?>
will actually print
bool(false)
bool(true)
If we were to change something in the really really ancient code, we
could completely get rid of the preg_match() check, because the next
check will work just fine for rejecting any input that is not an integer
between 0 and 255.
Previous Comments:
------------------------------------------------------------------------
[2011-02-16 14:03:21] hm2k
-Assigned To:
+Assigned To: mj
------------------------------------------------------------------------
[2011-02-15 17:46:42] hm2k
Patch attached.
I see no reason not to include this improvement.
------------------------------------------------------------------------
[2011-02-15 17:46:10] hm2k
Added #patch bug:17662;patch:net-checkip-no-regex;revision:1297791970;.
------------------------------------------------------------------------
[2010-08-09 09:41:56] hm2k
Instead of
if (!is_numeric($oct[$i])) {
Try:
if (!is_int($oct[$i])) {
Obviously is_numeric includes decimals, which is no good here.
------------------------------------------------------------------------
[2010-08-07 14:51:04] doconnor
-Type: Bug
+Type: Feature/Change Request
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=17662
[PEAR-BUG] Req #17662 [Opn]: Is there really need for a regex or does a PHP function do the trick?
| Tweet |
|
Search Discussions
Discussion Posts
Previous
Follow ups
- Hm2k: Edit report at http://pear.php.net/bugs/bug.php?id=17662&edit=1 ID: 17662 Updated by: hm2k@php.net Reported By: hm2k at php dot net Summary: Is there really need for a regex or does a PHP function do the trick? -Status: Wont fix +Status: Assigned Type: Feature/Change Request Package: Net_CheckIP Package Version: SVN PHP Version: Irrelevant Assigned To: mj Roadmap Versions: New Comment: -Status: Wont fix +Status: Assigned The idea here is to completely get rid of the preg_match, which isn't
- Mj: Edit report at http://pear.php.net/bugs/bug.php?id=17662&edit=1 ID: 17662 Updated by: mj@php.net Reported By: hm2k at php dot net Summary: Is there really need for a regex or does a PHP function do the trick? -Status: Assigned +Status: Wont fix Type: Feature/Change Request Package: Net_CheckIP Package Version: SVN PHP Version: Irrelevant Assigned To: mj Roadmap Versions: New Comment: -Status: Assigned +Status: Wont fix James, again, what you suggested will not work. <?php $var = "+127";
Related Discussions
Discussion Overview
| group | pear-bugs |
| categories | php |
| posted | Feb 15, '11 at 4:44p |
| active | Feb 28, '11 at 8:52p |
| posts | 5 |
| users | 2 |
| website | pear.php.net |
