MDL-38515 JavaScript: Detect use of invalid module names in YUI dependencies

A warning is shown in the browser console if debugging is set, but it is
not possible to return from the configFn and stop the module load attempt
from continuing.

The error is caught and an additional error is shown by yui_combo.php
This commit is contained in:
Andrew Robert Nicols
2013-03-16 20:42:55 +00:00
parent 09fe13d123
commit 4f65d03b08
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -197,7 +197,7 @@ class page_requirements_manager {
)
)
));
$configname = $this->YUI_config->set_config_function("var p = me.path, b = me.name.replace(/^moodle-/,'').split('-', 3), n = b.pop();if (/(skin|core)/.test(n)) {n = b.pop();me.type = 'css';};me.path = b.join('-')+'/'+n+'/'+n+'-min.'+me.type;");
$configname = $this->YUI_config->set_config_function("var p = me.path, b = me.name.replace(/^moodle-/,'').split('-', 3), n = b.pop();if (!b.length) {Y.log('Attempt to load invalid module name: ' + me.name, 'error'); return;} if (/(skin|core)/.test(n)) {n = b.pop();me.type = 'css';};me.path = b.join('-')+'/'+n+'/'+n+'-min.'+me.type;");
$this->YUI_config->add_group('moodle', array(
'name' => 'moodle',
'base' => $CFG->httpswwwroot . '/theme/yui_combo.php'.$sep.'moodle/'.$jsrev.'/',
+5
View File
@@ -83,6 +83,11 @@ foreach ($parts as $part) {
//debug($bits);
$version = array_shift($bits);
if ($version === 'moodle') {
if (count($bits) <= 3) {
// This is an invalid module load attempt.
$content .= "\n// Incorrect moodle module inclusion. Not enough component information in {$part}.\n";
continue;
}
if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
define('ABORT_AFTER_CONFIG_CANCEL', true);
define('NO_UPGRADE_CHECK', true);