Merge branch 'MDL-34107_filename_dot' of git://github.com/davosmith/moodle
This commit is contained in:
@@ -155,17 +155,22 @@ class repository_upload extends repository {
|
||||
$ext = '';
|
||||
$match = array();
|
||||
$filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
|
||||
if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) {
|
||||
if (isset($match[1])) {
|
||||
$ext = $match[1];
|
||||
}
|
||||
}
|
||||
$ext = !empty($ext) ? $ext : '';
|
||||
if (preg_match('#\.(' . $ext . ')$#i', $saveas_filename)) {
|
||||
// saveas filename contains file extension already
|
||||
if (strpos($filename, '.') === false) {
|
||||
// File has no extension at all - do not add a dot.
|
||||
$record->filename = $saveas_filename;
|
||||
} else {
|
||||
$record->filename = $saveas_filename . '.' . $ext;
|
||||
if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) {
|
||||
if (isset($match[1])) {
|
||||
$ext = $match[1];
|
||||
}
|
||||
}
|
||||
$ext = !empty($ext) ? $ext : '';
|
||||
if (preg_match('#\.(' . $ext . ')$#i', $saveas_filename)) {
|
||||
// saveas filename contains file extension already
|
||||
$record->filename = $saveas_filename;
|
||||
} else {
|
||||
$record->filename = $saveas_filename . '.' . $ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user