MDL-52068 repository: Prevent JS errors due to unescaped lang strings

This commit is contained in:
Frederic Massart 2016-02-18 19:26:00 +08:00
parent 03b8b55f10
commit 28f8993d0f

View File

@ -67,17 +67,21 @@ $repo->callback();
// If Moodle is working on HTTPS mode, then we are not allowed to access
// parent window, in this case, we need to alert user to refresh the repository
// manually.
$strhttpsbug = get_string('cannotaccessparentwin', 'repository');
$strhttpsbug = json_encode(get_string('cannotaccessparentwin', 'repository'));
$strrefreshnonjs = get_string('refreshnonjsfilepicker', 'repository');
$js =<<<EOD
<html>
<head>
<script type="text/javascript">
if(window.opener){
window.opener.M.core_filepicker.active_filepicker.list();
window.close();
} else {
alert("{$strhttpsbug }");
try {
if (window.opener) {
window.opener.M.core_filepicker.active_filepicker.list();
window.close();
} else {
throw new Error('Whoops!');
}
} catch (e) {
alert({$strhttpsbug});
}
</script>
</head>