### Eclipse Workspace Patch 1.0 #P moodle Index: lib/filterlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/filterlib.php,v retrieving revision 1.24.10.4 diff -u -r1.24.10.4 filterlib.php --- lib/filterlib.php 18 Feb 2009 11:02:11 -0000 1.24.10.4 +++ lib/filterlib.php 24 Aug 2009 00:35:51 -0000 @@ -52,8 +52,10 @@ * param link_array an array of filterobjects * param ignoretagsopen an array of opening tags that we should ignore while filtering * param ignoretagsclose an array of corresponding closing tags + * param overridedefaultignore boolean set to true to only use tags provided by arguments **/ -function filter_phrases ($text, &$link_array, $ignoretagsopen=NULL, $ignoretagsclose=NULL) { +function filter_phrases ($text, &$link_array, $ignoretagsopen=NULL, + $ignoretagsclose=NULL, $overridedefaultignore=false) { global $CFG; @@ -62,31 +64,35 @@ $ignoretags = array(); //To store all the enclosig tags to be completely ignored $tags = array(); //To store all the simple tags to be ignored -/// A list of open/close tags that we should not replace within -/// No reason why you can't put full preg expressions in here too -/// eg '' to match any type of script tag - $filterignoretagsopen = array('' , '' , ''); - $filterignoretagsclose = array('', '', ''); + if (!$overridedefaultignore) { + // A list of open/close tags that we should not replace within + // Extended to include ','', + '',''); + } else { + // Set an empty default list + $filterignoretagsopen = array(); + $filterignoretagsclose = array(); + } + // Add the user defined ignore tags to the default list + if ( is_array($ignoretagsopen) ) { + foreach ($ignoretagsopen as $open) $filterignoretagsopen[] = $open; + foreach ($ignoretagsclose as $close) $filterignoretagsclose[] = $close; + } + /// Invalid prefixes and suffixes for the fullmatch searches /// Every "word" character, but the underscore, is a invalid suffix or prefix. /// (nice to use this because it includes national characters (accents...) as word characters. $filterinvalidprefixes = '([^\W_])'; $filterinvalidsuffixes = '([^\W_])'; -/// Add the user defined ignore tags to the default list -/// Unless specified otherwise, we will not replace within tags - if ( $ignoretagsopen === NULL ) { - //$ignoretagsopen = array(''); - $ignoretagsopen = array(']+?>'); - $ignoretagsclose = array(''); - } - - if ( is_array($ignoretagsopen) ) { - foreach ($ignoretagsopen as $open) $filterignoretagsopen[] = $open; - foreach ($ignoretagsclose as $close) $filterignoretagsclose[] = $close; - } - //// Double up some magic chars to avoid "accidental matches" $text = preg_replace('/([#*%])/','\1\1',$text);