Permalink
Browse files

MDL-36526 calendar: calender ical import should allow webcal:// proto…

…cols
  • Loading branch information...
1 parent 8ccaa29 commit 12927e568b49c98f1118d853d807e78a89351d08 @ankitagarwal ankitagarwal committed Nov 13, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 calendar/managesubscriptions_form.php
@@ -58,7 +58,8 @@ public function definition() {
// URL.
$mform->addElement('text', 'url', get_string('importfromurl', 'calendar'), array('maxsize' => '255', 'size' => '50'));
- $mform->setType('url', PARAM_URL);
+ // Cannot set as PARAM_URL since we need to allow webcal:// protocol.
+ $mform->setType('url', PARAM_RAW);
// Import file
$mform->addElement('filepicker', 'importfile', get_string('importfromfile', 'calendar'));
@@ -103,12 +104,21 @@ public function definition() {
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
- if (empty($data['url']) && empty($data['importfile'])) {
+ $url = $data['url'];
+ if (empty($url) && empty($data['importfile'])) {
if (!empty($data['importfrom']) && $data['importfrom'] == CALENDAR_IMPORT_FROM_FILE) {
$errors['importfile'] = get_string('errorrequiredurlorfile', 'calendar');
} else {
$errors['url'] = get_string('errorrequiredurlorfile', 'calendar');
}
+ } elseif (!empty($url)) {
+ // Url is webcal protocol which is not accepted by PARAM_URL.
+ if (stripos($url, "webcal://") === 0) {
+ $url = substr($url, strlen("webcal://"));
+ }
+ if (clean_param($url, PARAM_URL) !== $url) {
+ $errors['url'] = get_string('invalidurl', 'error');
+ }
}
return $errors;
}

0 comments on commit 12927e5

Please sign in to comment.