The tilde character is not generally supported in Moodle. Previously it
was just removed silently and it was difficult to realize what was going
on.
return (int)$raw;
case input_manager::TYPE_PATH:
+ if (strpos($raw, '~') !== false) {
+ throw new invalid_option_exception('Using the tilde (~) character in paths is not supported');
+ }
$raw = str_replace('\\', '/', $raw);
$raw = preg_replace('~[[:cntrl:]]|[&<>"`\|\':]~u', '', $raw);
$raw = preg_replace('~\.\.+~', '', $raw);
$input->cast_value($invalid, input_manager::TYPE_MD5); // must throw exception
}
+ /**
+ * @expectedException invalid_option_exception
+ */
+ public function test_cast_tilde_in_path() {
+ $input = testable_input_manager::instance();
+ $invalid = '~/public_html/moodle_dev';
+ $input->cast_value($invalid, input_manager::TYPE_PATH); // must throw exception
+ }
+
public function test_has_option() {
$provider = input_fake_provider::instance();