]> git.mjollnir.org Git - moodle.git/commitdiff
moodlellib: MDL-19828 PARAM_LOCALURL should accept URLs like course/view.php?id=2
authortjhunt <tjhunt>
Wed, 15 Jul 2009 06:17:39 +0000 (06:17 +0000)
committertjhunt <tjhunt>
Wed, 15 Jul 2009 06:17:39 +0000 (06:17 +0000)
lib/moodlelib.php
lib/simpletest/testmoodlelib.php

index 708210593291a27d9f658e0eefd87174ef6a618e..2578f619630a8a28ddaf7d8cef62d7c3c24ce13e 100644 (file)
@@ -529,7 +529,7 @@ function clean_param($param, $type) {
                     // absolute, and matches our wwwroot
                 } else {
                     // relative - let's make sure there are no tricks
-                    if (validateUrlSyntax($param, 's-u-P-a-p-f+q?r?')) {
+                    if (validateUrlSyntax('/' . $param, 's-u-P-a-p-f+q?r?')) {
                         // looks ok.
                     } else {
                         $param = '';
index a571ef2a6411d81efe8a9756b56077f06d828761..ab55d43d22f35b1312e8bd99a7841bf795fe2bbf 100644 (file)
@@ -296,6 +296,7 @@ class moodlelib_test extends UnitTestCase {
         $this->assertEqual(clean_param($CFG->wwwroot, PARAM_LOCALURL), $CFG->wwwroot);
         $this->assertEqual(clean_param('/just/a/path', PARAM_LOCALURL), '/just/a/path');
         $this->assertEqual(clean_param('funny:thing', PARAM_LOCALURL), '');
+        $this->assertEqual(clean_param('course/view.php?id=3', PARAM_LOCALURL), 'course/view.php?id=3');
     }
 
     function test_make_user_directory() {