From 5604f5977f273901cc1cc8ec1d07e5be33929ce4 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Fri, 11 May 2018 17:33:08 +1000 Subject: [PATCH] MDL-62251 Privacy: Fix dir separator in export_file() --- privacy/classes/tests/request/content_writer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/privacy/classes/tests/request/content_writer.php b/privacy/classes/tests/request/content_writer.php index 3bd7e9da749..f91025a4e67 100644 --- a/privacy/classes/tests/request/content_writer.php +++ b/privacy/classes/tests/request/content_writer.php @@ -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);