MDL-55246 assign: convert files with spaces
authorMatt Davidson <davidso1@rose-hulman.edu>
Mon, 1 Aug 2016 14:46:08 +0000 (10:46 -0400)
committerMatt Davidson <davidso1@rose-hulman.edu>
Fri, 5 Aug 2016 12:14:20 +0000 (08:14 -0400)
If a file is sent to unoconv with a filename that contains spaces,
unoconv will fail to produce the intended results.

lib/filestorage/file_storage.php

index 18e3570..a9640e0 100644 (file)
@@ -354,9 +354,9 @@ class file_storage {
         // Copy the file to the tmp dir.
         $uniqdir = "core_file/conversions/" . uniqid($file->get_id() . "-", true);
         $tmp = make_temp_directory($uniqdir);
-        $localfilename = $file->get_filename();
+        $ext = pathinfo($file->get_filename(), PATHINFO_EXTENSION);
         // Safety.
-        $localfilename = clean_param($localfilename, PARAM_FILE);
+        $localfilename = $file->get_id() . '.' . $ext;
 
         $filename = $tmp . '/' . $localfilename;
         try {