MDL-50128 mod_data: String needed escaping before being used in regex
authorFrederic Massart <fred@moodle.com>
Wed, 6 May 2015 08:29:48 +0000 (16:29 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 7 May 2015 03:19:47 +0000 (11:19 +0800)
mod/data/lib.php

index 37959a0..9bd39ce 100644 (file)
@@ -885,7 +885,7 @@ function data_tags_check($dataid, $template) {
     // then we generate strings to replace
     $tagsok = true; // let's be optimistic
     foreach ($fields as $field){
-        $pattern="/\[\[".$field->name."\]\]/i";
+        $pattern="/\[\[" . preg_quote($field->name, '/') . "\]\]/i";
         if (preg_match_all($pattern, $template, $dummy)>1){
             $tagsok = false;
             echo $OUTPUT->notification('[['.$field->name.']] - '.get_string('multipletags','data'));