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

This commit is contained in:
Rajneel Totaram 2021-04-29 23:35:44 +12:00
parent 4ff86720bf
commit 7596e27989

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);