diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 09a1a8c69fc..fca36b38865 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -567,8 +567,12 @@ function clean_param($param, $type) { } case PARAM_TAG: + // Please note it is not safe to use the tag name directly anywhere, + // it must be processed with s(), urlencode() before embedding anywhere. + // remove some nasties + $param = preg_replace('~[[:cntrl:]]|[<>`]~u', '', $param); //as long as magic_quotes_gpc is used, a backslash will be a - //problem, so remove *all* backslash. + //problem, so remove *all* backslash - BUT watch out for SQL injections caused by this sloppy design (skodak) $param = str_replace('\\', '', $param); //convert many whitespace chars into one $param = preg_replace('/\s+/', ' ', $param); @@ -576,7 +580,6 @@ function clean_param($param, $type) { $param = $textlib->substr(trim($param), 0, TAG_MAX_LENGTH); return $param; - case PARAM_TAGLIST: $tags = explode(',', $param); $result = array(); diff --git a/tag/edit.php b/tag/edit.php index 7fa361ad518..7901e945676 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -4,7 +4,7 @@ require_once('../config.php'); require_once('lib.php'); require_once('edit_form.php'); -require_js(array('yui_dom-event', 'yui_connection', 'yui_animation', 'yui_autocomplete')); +require_js(array('yui_dom-event', 'yui_connection', 'yui_animation', 'yui_datasource', 'yui_autocomplete')); require_login(); @@ -92,21 +92,21 @@ if ($tagnew = $tagform->get_data()) { error('Error updating tag record'); } } - + //log tag changes activity //if tag name exist from form, renaming is allow. record log action as rename - //otherwise, record log action as update + //otherwise, record log action as update if (isset($tagnew->name) && ($tag->name != $tagnew->name)){ add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name . '->'. $tagnew->name); - } elseif ($tag->description != $tagnew->description) { + } elseif ($tag->description != $tagnew->description) { add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name); } - + //updated related tags tag_set('tag', $tagnew->id, explode(',', trim($tagnew->relatedtags))); //print_object($tagnew); die(); - + redirect($CFG->wwwroot.'/tag/index.php?tag='.rawurlencode($tag->name)); // must use $tag here, as the name isn't in the edit form } } @@ -133,9 +133,9 @@ if (ajaxenabled()) {