diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index ee0ea9512..d04c6031f 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -529,7 +529,6 @@ class e_parse extends e_parser $data = str_replace(array('%7B','%7D'),array('{','}'),$data); // fix for {e_XXX} paths. - // $data = urldecode($data); //XXX Commented out : NO LONGER REQUIRED. symptom of cleaning the HTML - urlencodes src attributes containing { and } .eg. {e_BASE} } @@ -1579,8 +1578,8 @@ class e_parse extends e_parser // $code_text = str_replace('&','&',$code_text); // validation safe. $html_start = ""; // markers for html-to-bbcode replacement. $html_end = ""; - $full_text = str_replace(array("[html]","[/html]"), "",$code_text); // quick fix.. security issue? - $full_text =$this->replaceConstants($full_text,'abs'); + $full_text = str_replace(array("[html]","[/html]"), "",$code_text); // quick fix.. security issue? + $full_text =$this->replaceConstants($full_text,'abs'); $full_text = $html_start.$full_text.$html_end; $full_text = $this->parseBBTags($full_text); // strip tags. $opts['nobreak'] = true; @@ -3012,6 +3011,7 @@ class e_parser protected $removedList = array(); protected $nodesToDelete = array(); protected $nodesToConvert = array(); + protected $nodesToDisableSC = array(); protected $pathList = array(); protected $allowedAttributes = array( 'default' => array('id', 'style', 'class'), @@ -3939,6 +3939,9 @@ TMPL; echo ""; + echo "

DB -> bbarea

"; + echo e107::getForm()->bbarea('name',$tp->toForm($dbText)); + } echo "

toDB() ≫ toHtml()

"; @@ -3971,6 +3974,9 @@ TMPL; echo "

Nodes to Convert

"; print_a($this->nodesToConvert); + + echo "

Nodes to Disable SC

"; + print_a($this->nodesToDisableSC); } similar_text($text, html_entity_decode( $toForm, ENT_COMPAT, 'UTF-8'),$perc); @@ -4181,17 +4187,25 @@ return; // echo "
Path = ".$path; // $tag = strval(basename($path)); + + + if(strpos($path,'/code/') !== false || strpos($path,'/pre/') !== false) // treat as html. + { + $this->pathList[] = $path; + $this->nodesToConvert[] = $node->parentNode; // $node; + continue; + } + + if(substr($path,-4) == '/pre' || substr($path,-5) == '/code') + { + $this->pathList[] = $path; + $this->nodesToDisableSC[] = $node; + } $tag = preg_replace('/([a-z0-9\[\]\/]*)?\/([\w]*)(\[(\d)*\])?$/i', "$2", $path); if(!in_array($tag, $this->allowedTags)) { - if(strpos($path,'/code/') !== false || strpos($path,'/pre/') !== false) // treat as html. - { - $this->pathList[] = $path; - $this->nodesToConvert[] = $node->parentNode; // $node; - continue; - } - + $this->removedList['tags'][] = $tag; $this->nodesToDelete[] = $node; continue; @@ -4248,7 +4262,20 @@ return; { $node->parentNode->removeChild($node); } - + + // Disable Shortcodes in pre/code + foreach($this->nodesToDisableSC as $node) + { + // $value = $node->C14N(); + $value = $node->nodeValue; + // $value = str_replace(" ","",$value); + $value = str_replace('{','{{{',$value); // temporarily change {e_XXX} to {{{e_XXX}}} + $value = str_replace('}','}}}',$value); // temporarily change {e_XXX} to {{{e_XXX}}} + $node->nodeValue = $value; + + } + + // Convert and
 Tags to Htmlentities. 
         foreach($this->nodesToConvert as $node)  
         {
@@ -4274,9 +4301,13 @@ return;
             $node->nodeValue = $value;
         }
 
+
         $cleaned = $doc->saveHTML($doc->documentElement); // $doc->documentElement fixes utf-8/entities issue. @see http://stackoverflow.com/questions/8218230/php-domdocument-loadhtml-not-encoding-utf-8-correctly
 
-		$cleaned = str_replace ('@nbsp;', ' ',  $cleaned); // prevent replacement of   with spaces. - convert back.
+		$cleaned = str_replace('@nbsp;', ' ',  $cleaned); // prevent replacement of   with spaces. - convert back.
+
+		$cleaned = str_replace('{{{','{', $cleaned); // convert shortcode temporary triple-curly braces back to entities.
+	    $cleaned = str_replace('}}}','}', $cleaned); // convert shortcode temporary triple-curly braces back to entities.
 
         $cleaned = str_replace(array('','','','','','',''),'',$cleaned); // filter out tags.