From 76f93178a8f7456adcc9802ec2b8ebce08fa25ba Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 25 Jun 2012 19:15:52 +0530 Subject: [PATCH] Tweaked Validation::extension() --- lib/Cake/Utility/Validation.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index d08c227ae..d709732d9 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -442,17 +442,16 @@ class Validation { * Check that value has a valid file extension. * * @param string|array $check Value to check - * @param array $extensions file extensions to allow + * @param array $extensions file extensions to allow. By default extensions are 'gif', 'jpeg', 'png', 'jpg' * @return boolean Success */ public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { if (is_array($check)) { return self::extension(array_shift($check), $extensions); } - $pathSegments = explode('.', $check); - $extension = strtolower(array_pop($pathSegments)); + $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION)); foreach ($extensions as $value) { - if ($extension == strtolower($value)) { + if ($extension === strtolower($value)) { return true; } }