Fix #7212 - htmlspecialchars wrapper - as null not supported anymore
authorAlan <alan@roojs.com>
Tue, 3 May 2022 05:09:18 +0000 (13:09 +0800)
committerAlan <alan@roojs.com>
Tue, 3 May 2022 05:09:18 +0000 (13:09 +0800)
HTML/Template/Flexy.php
HTML/Template/Flexy/Compiler/Flexy.php

index f501a9c..c2f98c2 100644 (file)
@@ -612,7 +612,7 @@ class HTML_Template_Flexy
         
         
         // initialize the translator..
-        include($this->compiledTemplate);
+        include $this->compiledTemplate;
         
         self::$activeEngine = $__old_engine;
         
@@ -1123,5 +1123,15 @@ class HTML_Template_Flexy
     {
         return $this->bufferedOutputObject($object);
     }
+    /**
+     * htmlspecialchars
+     */
+    static function htmlspecialchars($str, $flags = 0)
+    {
+        if (is_null($str)) {
+            return '';
+        }
+        return htmlspecialchars($str, $flags, 'UTF-8');
+    }
     
 }
index 7050b95..46e23cb 100644 (file)
@@ -179,9 +179,7 @@ class HTML_Template_Flexy_Compiler_Flexy extends HTML_Template_Flexy_Compiler {
             $flexy->elements =  $GLOBALS['_HTML_TEMPLATE_FLEXY']['elements'];
             return $data;
         }
-        
-        
-        
+         
         
         // error checking?
         $file  = $flexy->compiledTemplate;
@@ -516,7 +514,7 @@ class HTML_Template_Flexy_Compiler_Flexy extends HTML_Template_Flexy_Compiler {
         $prefix = 'echo ';
         
         $suffix = '';
-        $modifier = strlen(trim($element->modifier)) ? $element->modifier : ' ';
+        $modifier = $element->modifier && strlen(trim($element->modifier)) ? $element->modifier : ' ';
         
         switch ($modifier) {
             case 'h':
@@ -536,19 +534,19 @@ class HTML_Template_Flexy_Compiler_Flexy extends HTML_Template_Flexy_Compiler {
                 $suffix = $GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']['numberFormat'] . ')';
                 break;
             case 'b': // nl2br + htmlspecialchars
-                $prefix = 'echo nl2br(htmlspecialchars(';
+                $prefix = 'echo nl2br(self::htmlspecialchars(';
                 
                 // add language ?
                 $suffix = '))';
                 break;
             case 'e':
-                $prefix = 'echo htmlentities(';
+                $prefix = 'echo self::htmlentities(';
                 // add language ?
                 $suffix = ')';
                 break;
              
             case ' ':
-                $prefix = 'echo htmlspecialchars(';
+                $prefix = 'echo self::htmlspecialchars(';
                 // add language ?
                 $suffix = ',ENT_IGNORE)';
                 break;