Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweaked Validation::extension()

  • Loading branch information...
commit 76f93178a8f7456adcc9802ec2b8ebce08fa25ba 1 parent ad53458
@ADmad ADmad authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/Cake/Utility/Validation.php
View
7 lib/Cake/Utility/Validation.php
@@ -442,17 +442,16 @@ public static function equalTo($check, $comparedTo) {
* 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;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.