From 1502c871bdd6e26ac05e76279b6b9f5d8bad8620 Mon Sep 17 00:00:00 2001 From: Myles Carrick Date: Thu, 14 Apr 2011 13:22:03 +1000 Subject: [PATCH 03/11] MOODLE-33: clean URLS when validating and when adding an instance - replace anything non-alphanumeric with hyphens --- lib.php | 14 ++++++++++++++ mod_form.php | 2 +- 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/lib.php b/lib.php index a07228c..ee08fb3 100644 --- a/lib.php +++ b/lib.php @@ -70,6 +70,7 @@ function adobeconnect_add_instance($adobeconnect) { global $COURSE, $USER, $DB; $adobeconnect->timecreated = time(); + $adobeconnect->meeturl = adobeconnect_clean_meet_url($adobeconnect->meeturl); $return = false; $meeting = new stdClass(); @@ -545,3 +546,16 @@ function adobeconnect_scale_used_anywhere($scaleid) { return false; } } + + +/** + * Meeting URLs need to start with an alpha then be alphanumeric + * or hyphen('-') + * + * @param string $meeturl Incoming URL + * @return string cleaned URL + */ +function adobeconnect_clean_meet_url($meeturl) { + $meeturl = preg_replace ('/[^a-z0-9]/i', '-', $meeturl); + return $meeturl; +} \ No newline at end of file diff --git a/mod_form.php b/mod_form.php index 48f00ac..c1d4d1f 100644 --- a/mod_form.php +++ b/mod_form.php @@ -128,7 +128,7 @@ class mod_adobeconnect_mod_form extends moodleform_mod { } // Now search for existing meeting room URLs - $url = $data['meeturl']; + $url = $data['meeturl'] = adobeconnect_clean_meet_url($data['meeturl']); // Check to see if there are any trailing slashes or additional parts to the url // ex. mymeeting/mysecondmeeting/ Only the 'mymeeting' part is valid -- 1.7.2.2