]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18165 filterlib - Use one exclusive separator, instead of "." (dot) to avoid...
authorstronk7 <stronk7>
Sat, 7 Feb 2009 00:59:56 +0000 (00:59 +0000)
committerstronk7 <stronk7>
Sat, 7 Feb 2009 00:59:56 +0000 (00:59 +0000)
lib/filterlib.php

index 0fb005d6e250535d01b549ba35d99f4ed3cc41aa..17d00ef4507f3a117ba4f46a693c08b2fa7066e9 100644 (file)
@@ -53,6 +53,11 @@ abstract class filter_base {
     abstract function filter($text);
 }
 
+/// Define one exclusive separator that we'll use in the temp saved tags
+/// keys. It must be something rare enough to avoid having matches with
+/// filterobjects. MDL-18165
+define ('EXCL_SEPARATOR', '-%-');
+
 /**
  * This is just a little object to define a phrase and some instructions 
  * for how to process it.  Filters can create an array of these to pass 
@@ -322,7 +327,7 @@ function filter_remove_duplicates($linkarray) {
 /**
  * Extract open/lose tags and their contents to avoid being processed by filters.
  * Useful to extract pieces of code like <a>...</a> tags. It returns the text
- * converted with some <#x.x#> codes replacing the extracted text. Such extracted
+ * converted with some <#xEXCL_SEPARATORx#> codes replacing the extracted text. Such extracted
  * texts are returned in the ignoretags array (as values), with codes as keys.
  *
  * param  text                  the text that we are filtering (in/out)
@@ -343,7 +348,7 @@ function filter_save_ignore_tags(&$text,$filterignoretagsopen,$filterignoretagsc
         preg_match_all($pregexp, $text, $list_of_ignores);
         foreach (array_unique($list_of_ignores[0]) as $key=>$value) {
             $prefix = (string)(count($ignoretags) + 1);
-            $ignoretags['<#'.$prefix.'.'.$key.'#>'] = $value;
+            $ignoretags['<#'.$prefix.EXCL_SEPARATOR.$key.'#>'] = $value;
         }
         if (!empty($ignoretags)) {
             $text = str_replace($ignoretags,array_keys($ignoretags),$text);
@@ -353,7 +358,7 @@ function filter_save_ignore_tags(&$text,$filterignoretagsopen,$filterignoretagsc
 
 /**
  * Extract tags (any text enclosed by < and > to avoid being processed by filters.
- * It returns the text converted with some <%x.x%> codes replacing the extracted text. Such extracted
+ * It returns the text converted with some <%xEXCL_SEPARATORx%> codes replacing the extracted text. Such extracted
  * texts are returned in the tags array (as values), with codes as keys.
  *      
  * param  text   the text that we are filtering (in/out)
@@ -364,7 +369,7 @@ function filter_save_tags(&$text,&$tags) {
     preg_match_all('/<([^#%*].*?)>/is',$text,$list_of_newtags);
     foreach (array_unique($list_of_newtags[0]) as $ntkey=>$value) {
         $prefix = (string)(count($tags) + 1);
-        $tags['<%'.$prefix.'.'.$ntkey.'%>'] = $value;
+        $tags['<%'.$prefix.EXCL_SEPARATOR.$ntkey.'%>'] = $value;
     }
     if (!empty($tags)) {
         $text = str_replace($tags,array_keys($tags),$text);