MDL-71343 core_h5p: Convert all line-endings to UNIX format

This commit is contained in:
Rajneel Totaram
2021-05-01 00:05:30 +12:00
parent 9a4a49f060
commit c217daf2a4
+2
View File
@@ -409,6 +409,8 @@ class helper {
* @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);