From 063b4fe03af2f828776a697c9ef8571460732cfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 9 May 2005 16:14:00 +0000 Subject: [PATCH] * Switching is_numeric() in isByte(), isShort() and isLong() out for sprintf() per wegges suggestion because: 1. $in can't be a floating point number 2. When typecast php ignores any non-integers after the first row of integers 3. A regular expression would be slower and insanely complex * Insert kind comments about php and remarks about how much I appriciate its existance here* --- includes/Exif.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Exif.php b/includes/Exif.php index e0b67275e1..f62dbc80ab 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -305,7 +305,7 @@ class Exif { */ function isByte( $in ) { $fname = 'isByte'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 255 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 255 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else { @@ -321,7 +321,7 @@ class Exif { function isShort( $in ) { $fname = 'isShort'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 65536 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 65536 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else { @@ -332,7 +332,7 @@ class Exif { function isLong( $in ) { $fname = 'isLong'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 4294967296 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 4294967296 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else { -- 2.20.1