Skip to content

Commit 1f8a160

Browse files
committed
Check that pathinfo() has returned an extension
Prevent the notice that is generated when pathinfo() doesn't return an 'extension' element in Zend_Validate_File_Extension. Fixes zendframework#287
1 parent 87bcf4c commit 1f8a160

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Validate/File/Extension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ public function isValid($value, $file = null)
196196
$info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1);
197197
} else {
198198
$info = pathinfo($value);
199+
if (!array_key_exists('extension', $info)) {
200+
// From the manual at http://php.net/pathinfo:
201+
// "If the path does not have an extension, no extension element
202+
// will be returned (see second example below)."
203+
return false;
204+
}
199205
}
200206

201207
$extensions = $this->getExtension();

0 commit comments

Comments
 (0)