From c217daf2a43ca48eae4086b2c8eaf9e32a2bac9e Mon Sep 17 00:00:00 2001 From: Rajneel Totaram Date: Thu, 29 Apr 2021 23:31:33 +1200 Subject: [PATCH] MDL-71343 core_h5p: Convert all line-endings to UNIX format --- h5p/classes/helper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/h5p/classes/helper.php b/h5p/classes/helper.php index e88fe63bc5546..f79c761dcfb13 100644 --- a/h5p/classes/helper.php +++ b/h5p/classes/helper.php @@ -409,6 +409,8 @@ public static function get_cache_librarykey(string $library): string { * @return array The JS array converted to PHP array. */ public static function parse_js_array(string $jscontent): array { + // Convert all line-endings to UNIX format first. + $jscontent = str_replace(array("\r\n", "\r"), "\n", $jscontent); $jsarray = preg_split('/,\n\s+/', substr($jscontent, 0, -1)); $jsarray = preg_replace('~{?\\n~', '', $jsarray);