From 47164284f7733d2f3eb525c1e3002d00aff8d438 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 27 Sep 2013 12:50:28 +1000 Subject: [PATCH] MDL-41921 mod_url: less restrictions on URL field Restoring functionality from 2.4 accidentally removed in MDL-34311 --- mod/url/mod_form.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mod/url/mod_form.php b/mod/url/mod_form.php index e4790d75e35..5c1e675bd36 100644 --- a/mod/url/mod_form.php +++ b/mod/url/mod_form.php @@ -51,7 +51,7 @@ class mod_url_mod_form extends moodleform_mod { //------------------------------------------------------- $mform->addElement('header', 'content', get_string('contentheader', 'url')); $mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true)); - $mform->setType('externalurl', PARAM_URL); + $mform->setType('externalurl', PARAM_RAW_TRIMMED); $mform->addRule('externalurl', null, 'required', null, 'client'); $mform->setExpanded('content'); @@ -165,15 +165,9 @@ class mod_url_mod_form extends moodleform_mod { // NOTE: do not try to explain the difference between URL and URI, people would be only confused... - if (empty($data['externalurl'])) { - $errors['externalurl'] = get_string('required'); - - } else { - $url = trim($data['externalurl']); - if (empty($url)) { - $errors['externalurl'] = get_string('required'); - - } else if (preg_match('|^/|', $url)) { + if (!empty($data['externalurl'])) { + $url = $data['externalurl']; + if (preg_match('|^/|', $url)) { // links relative to server root are ok - no validation necessary } else if (preg_match('|^[a-z]+://|i', $url) or preg_match('|^https?:|i', $url) or preg_match('|^ftp:|i', $url)) {