MDL-62251 Privacy: Fix dir separator in export_file()

This commit is contained in:
Shamim Rezaie
2018-05-11 17:33:08 +10:00
parent 6d882faecf
commit 5604f5977f
@@ -396,7 +396,10 @@ class content_writer implements \core_privacy\local\request\content_writer {
*/
public function export_file(array $subcontext, \stored_file $file) : \core_privacy\local\request\content_writer {
if (!$file->is_directory()) {
$filepath = explode(DIRECTORY_SEPARATOR, $file->get_filepath());
$filepath = $file->get_filepath();
// Directory separator in the stored_file class should always be '/'. The following line is just a fail safe.
$filepath = str_replace(DIRECTORY_SEPARATOR, '/', $filepath);
$filepath = explode('/', $filepath);
$filepath[] = $file->get_filename();
$filepath = array_filter($filepath);
$filepath = implode('/', $filepath);