]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15897: Changed admin_setting_configtext.validate() check to not treat all strings...
authorashleyholman <ashleyholman>
Fri, 18 Sep 2009 03:52:50 +0000 (03:52 +0000)
committerashleyholman <ashleyholman>
Fri, 18 Sep 2009 03:52:50 +0000 (03:52 +0000)
Instead require them to have '/' at the beginning and end of the pattern.

The only setting that appears to use a custom regex is scorm/apidebugmask - now updated to contain surrounding slashes.

lib/adminlib.php
mod/scorm/settings.php

index 3c9fd6befa06d963aab935115e794ba18de850a3..b8014159a05c725845c7c6133d1c1dbb13d64c9e 100644 (file)
@@ -1508,7 +1508,8 @@ class admin_setting_configtext extends admin_setting {
      * @return mixed true if ok string if error found
      */
     public function validate($data) {
-        if (is_string($this->paramtype)) {
+        // allow paramtype to be a custom regex if it is the form of /pattern/
+        if (preg_match('#^/.*/$#', $this->paramtype)) {
             if (preg_match($this->paramtype, $data)) {
                 return true;
             } else {
index 5212f3a2e1c6001e9110a38c2ac879f5f959dfea..b7078c9068d4f027a6db8e5b98dacbd6fe261fe2 100644 (file)
@@ -56,6 +56,6 @@ $settings->add(new admin_setting_configcheckbox('scorm/allowtypeimsrepository',
 
 $settings->add(new admin_setting_configcheckbox('scorm/allowapidebug', get_string('allowapidebug', 'scorm'), '', 0));
 
-$settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '.*'));
+$settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '/.*/'));
 
-?>
\ No newline at end of file
+?>