[pLog-svn] r7244 - plog/branches/lifetype-1.2/class/data

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Wed Jul 15 07:58:11 EDT 2020


Author: jondaley
Date: 2020-07-15 07:58:11 -0400 (Wed, 15 Jul 2020)
New Revision: 7244

Modified:
   plog/branches/lifetype-1.2/class/data/kses.class.php
   plog/branches/lifetype-1.2/class/data/textfilter.class.php
Log:
PHP 5.3 compatibility fixes.  PHP5.4+ fixes all of these

Modified: plog/branches/lifetype-1.2/class/data/kses.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/kses.class.php	2020-07-15 11:36:52 UTC (rev 7243)
+++ plog/branches/lifetype-1.2/class/data/kses.class.php	2020-07-15 11:58:11 UTC (rev 7244)
@@ -225,6 +225,8 @@
 		###############################################################################
 		function _normalize_entities($string)
 		{
+      $self = $this;
+
 			# Disarm all entities by converting & to &
 		  $string = str_replace('&', '&', $string);
 
@@ -233,7 +235,7 @@
 		  $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string);
 		  $string = preg_replace_callback(
 		  				   '/&#0*([0-9]{1,5});/', 
-						   function($m) { return $this->_normalize_entities2($m[1]); }, 
+                 function($m) use($self) { return $self->_normalize_entities2($m[1]); }, 
 						   $string
 		  ); 
 		  $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
@@ -246,7 +248,7 @@
 		  
 		       // also, normalize whatever is within <code>...</code> tags but only in the "xhtml converter" mode
     		   $string = preg_replace_callback("/(.*<code>)(.*)(<\/code>.*)/",
-                                               function($m){ return $m[1].$this->_tmp($m[2]).$m[3]; }, $string );    		   
+                                           function($m) use($self){ return $m[1].$self->_tmp($m[2]).$m[3]; }, $string );    		   
           }  
 
 		  return $string;
@@ -254,11 +256,12 @@
 		
 		function _tmp($string)
 		{
+      $self = $this;
 		  $string = htmlspecialchars($string);		
 		  $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string);
 		  $string = preg_replace_callback(
 		  				    '/&#0*([0-9]{1,5});/',
-						    function($m) { return $this->_normalize_entities2($m[1]); },
+                  function($m) use($self) { return $self->_normalize_entities2($m[1]); },
 						    $string
 		  );
 		  $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
@@ -311,12 +314,13 @@
 		###############################################################################
 		function _split($string)
 		{
+      $self = $this;
 			return preg_replace_callback(
 				'%(<'.   # EITHER: <
 				'[^>]*'. # things that aren't >
 				'>'.     # must >
 				'|>)%', # OR: just a >
-				function($m) { return $this->_split2($m[1]); },
+				function($m) use($self) { return $self->_split2($m[1]); },
 				$string);
 		} # function _split
 
@@ -609,10 +613,11 @@
 		###############################################################################
 		function _bad_protocol_once($string)
 		{
+      $self = $this;
 			return preg_replace_callback(
 				'/^((&[^;]*;|[\sA-Za-z0-9])*)'.
 				'(:|:|&#[Xx]3[Aa];)(\/|/|&#[Xx]2[Ff];)(\/|/|&#[Xx]2[Ff];)\s*/',
-				function($m){ return $this->_bad_protocol_once2($m[1]); },
+				function($m) use($self) { return $self->_bad_protocol_once2($m[1]); },
 				$string
 			);
 		} # function _bad_protocol_once

Modified: plog/branches/lifetype-1.2/class/data/textfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/textfilter.class.php	2020-07-15 11:36:52 UTC (rev 7243)
+++ plog/branches/lifetype-1.2/class/data/textfilter.class.php	2020-07-15 11:58:11 UTC (rev 7244)
@@ -235,7 +235,10 @@
             $htmlString = preg_replace_callback('~&#([0-9]+);~',
                                                 function($m){ return chr($m[1]); }, $htmlString);
             // get the entity translation table from PHP (current encoding is ISO-8859-1)
-            $trans_table = get_html_translation_table( HTML_ENTITIES, $quote_style, "ISO-8859-1" );
+            if (PHP_VERSION_ID < 50304) 
+              $trans_table = get_html_translation_table( HTML_ENTITIES, $quote_style );
+            else
+              $trans_table = get_html_translation_table( HTML_ENTITIES, $quote_style, "ISO-8859-1" );
             // when we want to decode the input string to normalized string, there are two factors 
             // we need to take into consideration:
             //  - Input string encoding



More information about the pLog-svn mailing list