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

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Wed Jul 15 05:48:32 EDT 2020


Author: jondaley
Date: 2020-07-15 05:48:32 -0400 (Wed, 15 Jul 2020)
New Revision: 7239

Modified:
   plog/branches/lifetype-1.2/class/data/inputfilter.class.php
   plog/branches/lifetype-1.2/class/data/kses.class.php
   plog/branches/lifetype-1.2/class/data/textfilter.class.php
Log:
I think we should only use my_preg_replace if the deprecated 'e' tag is used; there is a bug currently in the xhtmlize filter, so trying to narrow down where it is coming from

Modified: plog/branches/lifetype-1.2/class/data/inputfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/inputfilter.class.php	2020-07-15 07:59:26 UTC (rev 7238)
+++ plog/branches/lifetype-1.2/class/data/inputfilter.class.php	2020-07-15 09:48:32 UTC (rev 7239)
@@ -220,7 +220,7 @@
 				$attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]);
 				// strip normal newline within attr value
             // jondaley/lifetype: this also stripped out all whitespace, not just newlines
-				$attrSubSet[1] = my_preg_replace('/\n\r/', '', $attrSubSet[1]);
+				$attrSubSet[1] = preg_replace('/\n\r/', '', $attrSubSet[1]);
 				// strip double quotes
 				$attrSubSet[1] = str_replace('"', '', $attrSubSet[1]);
 				// [requested feature] convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value)
@@ -266,6 +266,7 @@
         // post HTML source in their posts, ie. < etc.
 //		$source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
 		// convert decimal
+        // TODO: check this
 		$source = my_preg_replace('/&#(\d+);/me',"chr(\\1)", $source);				// decimal notation
 		// convert hex
 		$source = preg_replace_callback(
@@ -277,4 +278,4 @@
 	}
 }
 
-?>
\ No newline at end of file
+?>

Modified: plog/branches/lifetype-1.2/class/data/kses.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/kses.class.php	2020-07-15 07:59:26 UTC (rev 7238)
+++ plog/branches/lifetype-1.2/class/data/kses.class.php	2020-07-15 09:48:32 UTC (rev 7239)
@@ -202,8 +202,8 @@
 		###############################################################################
 		function _no_null($string)
 		{
-			$string = my_preg_replace('/\0+/', '', $string);
-			$string = my_preg_replace('/(\\\\0)+/', '', $string);
+			$string = preg_replace('/\0+/', '', $string);
+			$string = preg_replace('/(\\\\0)+/', '', $string);
 			//
 			// NOTE TO SELF: this was apparently messing up utf-8 texts!!! Removed for now...
 			//
@@ -217,7 +217,7 @@
 		###############################################################################
 		function _js_entities($string)
 		{
-		  return my_preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
+		  return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
 		} # function _js_entities
 
 
@@ -232,21 +232,22 @@
 
 			# Change back the allowed entities in our entity white list
 
-		  $string = my_preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $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]); }, 
 						   $string
 		  ); 
-		  $string = my_preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
+		  $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
 		  
 		  if( $this->xhtmlConverterOnly && $this->aggressiveMode ) {
 		      // take care of the '>' and '<' that don't belong to any tag
-		      $string = my_preg_replace("/(\s+)(<)(\s+)/", "\\1<\\3", $string );
-		      $string = my_preg_replace("/(\[^A-Za-z]+)(<)([^A-Za-z]+)/", "\\1<\\3", $string );		      
-		      $string = my_preg_replace("/(\s+)(>)(\s+)/", "\\1>\\3", $string );		  
+		      $string = preg_replace("/(\s+)(<)(\s+)/", "\\1<\\3", $string );
+		      $string = preg_replace("/(\[^A-Za-z]+)(<)([^A-Za-z]+)/", "\\1<\\3", $string );		      
+		      $string = preg_replace("/(\s+)(>)(\s+)/", "\\1>\\3", $string );		  
 		  
-		       // also, normalize whatever is within <code>...</code> tags but only in the "xhtml converter" mode		  
+		       // also, normalize whatever is within <code>...</code> tags but only in the "xhtml converter" mode
+                  // TODO: need to check this one
     		   $string = my_preg_replace("/(.*<code>)(.*)(<\/code>.*)/e", '"\\1".$this->_tmp("\\2")."\\3"', $string );    		   
           }  
 
@@ -256,13 +257,13 @@
 		function _tmp($string)
 		{
 		  $string = htmlspecialchars($string);		
-		  $string = my_preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $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]); },
 						    $string
 		  );
-		  $string = my_preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
+		  $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
 		  
 		  return $string;		
 		}
@@ -431,7 +432,7 @@
 			} # foreach
 
 			# Remove any "<" or ">" characters
-			$attr2 = my_preg_replace('/[<>]/', '', $attr2);
+			$attr2 = preg_replace('/[<>]/', '', $attr2);
 			return "<$element$attr2$xhtml_slash>";
 		} # function _attr
 
@@ -462,7 +463,7 @@
 						{
 							$attrname = strtolower($match[1]);
 							$working = $mode = 1;
-							$attr = my_preg_replace('/^[-a-zA-Z]+/', '', $attr);
+							$attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
 						}
 						break;
 					case 1:	# equals sign or valueless ("selected")
@@ -470,7 +471,7 @@
 						{
 							$working = 1;
 							$mode    = 2;
-							$attr    = my_preg_replace('/^\s*=\s*/', '', $attr);
+							$attr    = preg_replace('/^\s*=\s*/', '', $attr);
 							break;
 						}
 						if (preg_match('/^\s+/', $attr)) # valueless
@@ -483,7 +484,7 @@
 								'whole' => $attrname,
 								'vless' => 'y'
 							);
-							$attr      = my_preg_replace('/^\s+/', '', $attr);
+							$attr      = preg_replace('/^\s+/', '', $attr);
 						}
 						break;
 					case 2: # attribute value, a URL after href= for instance
@@ -498,7 +499,7 @@
 							);
 							$working   = 1;
 							$mode      = 0;
-							$attr      = my_preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
+							$attr      = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
 							break;
 						}
 						if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) # 'value'
@@ -512,7 +513,7 @@
 							);
 							$working   = 1;
 							$mode      = 0;
-							$attr      = my_preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
+							$attr      = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
 							break;
 						}
 						if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) # value
@@ -527,7 +528,7 @@
 							# We add quotes to conform to W3C's HTML spec.
 							$working   = 1;
 							$mode      = 0;
-							$attr      = my_preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
+							$attr      = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
 						}
 						if( $this->xhtmlConverterOnly ) {												
                             if (preg_match("%^([^\s\"']+)(\s+|\"$)%", $attr, $match)) # value"
@@ -542,7 +543,7 @@
                                 # We add quotes to conform to W3C's HTML spec.
                                 $working   = 1;
                                 $mode      = 0;
-                                $attr      = my_preg_replace("%^[^\s\"']+(\s+|\"$)%", '', $attr);
+                                $attr      = preg_replace("%^[^\s\"']+(\s+|\"$)%", '', $attr);
                             }
                             if (preg_match("%^\"(.*)$%", $attr, $match)) # "value
                             {
@@ -556,7 +557,7 @@
                                 # We add quotes to conform to W3C's HTML spec.
                                 $working   = 1;
                                 $mode      = 0;
-                                $attr      = my_preg_replace("%^\"(.*)$%", '', $attr);
+                                $attr      = preg_replace("%^\"(.*)$%", '', $attr);
                             }
 						}
 						
@@ -626,7 +627,7 @@
 		function _bad_protocol_once2($string)
 		{
 			$string2 = $this->_decode_entities($string);
-			$string2 = my_preg_replace('/\s/', '', $string2);
+			$string2 = preg_replace('/\s/', '', $string2);
 			$string2 = $this->_no_null($string2);
 			$string2 = strtolower($string2);
 			
@@ -732,7 +733,7 @@
 		###############################################################################
 		function _stripslashes($string)
 		{
-			return my_preg_replace('%\\\\"%', '"', $string);
+			return preg_replace('%\\\\"%', '"', $string);
 		} # function _stripslashes
 
 		###############################################################################
@@ -742,7 +743,7 @@
 		###############################################################################
 		function _html_error($string)
 		{
-			$result = my_preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string);
+			$result = preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string);
 			return $result;
 		} # function _html_error
 
@@ -753,7 +754,8 @@
 		###############################################################################
 		function _decode_entities($string)
 		{
-			$string = my_preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string);
+			$string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string);
+                // TODO: need to check this
 			$string = my_preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', $string);
 			return $string;
 		} # function _decode_entities

Modified: plog/branches/lifetype-1.2/class/data/textfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/textfilter.class.php	2020-07-15 07:59:26 UTC (rev 7238)
+++ plog/branches/lifetype-1.2/class/data/textfilter.class.php	2020-07-15 09:48:32 UTC (rev 7239)
@@ -68,11 +68,11 @@
             }
 
                 // WP bug fix for LOVE <3 (and other situations with '<' before a number)
-            $string = my_preg_replace('/<([0-9]+)/', '<$1', $string);
+            $string = preg_replace('/<([0-9]+)/', '<$1', $string);
                 // some nice people might like to use "<  >" without meaning to do HTML?
-            $string = my_preg_replace('/<( *)>/', '<$1>', $string);
+            $string = preg_replace('/<( *)>/', '<$1>', $string);
         
-//            $string = my_preg_replace('/<.*>/', '<', $string);
+//            $string = preg_replace('/<.*>/', '<', $string);
 
 			$string = strip_tags( $string, $htmlAllowedTags );
             $string = TextFilter::balanceTags($string);
@@ -106,8 +106,7 @@
 		 */
 		function filterHTMLEntities( $string )
 		{
-//			return htmlentities( $string );
-			return htmlspecialchars( $string );
+			return htmlentities( $string );
 		}
 
         /**
@@ -157,23 +156,23 @@
                     $curl = str_replace("...", '…', $curl);
                     $curl = str_replace('``', '“', $curl);
 
-                    $curl = my_preg_replace("/'s/", "’s", $curl);
-                    $curl = my_preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl);
-                    $curl = my_preg_replace('/(\s|\A|")\'/', '$1‘', $curl);
-                    $curl = my_preg_replace("/(\d+)\"/", "$1″", $curl);
-                    $curl = my_preg_replace("/(\d+)'/", "$1′", $curl);
-                    $curl = my_preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl);
-                    $curl = my_preg_replace('/"([\s.]|\Z)/', '”$1', $curl);
-                    $curl = my_preg_replace('/(\s|\A)"/', '$1“', $curl);
-                    $curl = my_preg_replace("/'([\s.]|\Z)/", '’$1', $curl);
-                    $curl = my_preg_replace("/\(tm\)/i", '™', $curl);
-                    $curl = my_preg_replace("/\(c\)/i", '©', $curl);
-                    $curl = my_preg_replace("/\(r\)/i", '®', $curl);
+                    $curl = preg_replace("/'s/", "’s", $curl);
+                    $curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl);
+                    $curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl);
+                    $curl = preg_replace("/(\d+)\"/", "$1″", $curl);
+                    $curl = preg_replace("/(\d+)'/", "$1′", $curl);
+                    $curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl);
+                    $curl = preg_replace('/"([\s.]|\Z)/', '”$1', $curl);
+                    $curl = preg_replace('/(\s|\A)"/', '$1“', $curl);
+                    $curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl);
+                    $curl = preg_replace("/\(tm\)/i", '™', $curl);
+                    $curl = preg_replace("/\(c\)/i", '©', $curl);
+                    $curl = preg_replace("/\(r\)/i", '®', $curl);
 
                     $curl = str_replace("''", '”', $curl);
-                    $curl = my_preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $curl);
+                    $curl = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $curl);
 
-                    $curl = my_preg_replace('/(d+)x(\d+)/', "$1×$2", $curl);
+                    $curl = preg_replace('/(d+)x(\d+)/', "$1×$2", $curl);
                } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
                		// strstr is fast
             		$next = false;
@@ -197,13 +196,13 @@
          */
 		function autoP($pee, $br=1)
         {
-			$pee = my_preg_replace("/(\r\n|\n|\r)/", "\n", $pee); // cross-platform newline
-            $pee = my_preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
-        	$pee = my_preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
-        	$pee = my_preg_replace('/<p>(<(?:table|[ou]l|pre|select|form|blockquote)>)/', "$1", $pee);
-        	$pee = my_preg_replace('!(</?(?:table|[ou]l|pre|select|form|blockquote)>)</p>!', "$1", $pee);
-        	if ($br) $pee = my_preg_replace('|(?<!</p>)\s*\n|', "<br />\n", $pee); // optionally make line breaks
-        	$pee = my_preg_replace('!(</(?:table|[ou]l|pre|select|form|blockquote)>)<br />!', "$1", $pee);
+			$pee = preg_replace("/(\r\n|\n|\r)/", "\n", $pee); // cross-platform newline
+            $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
+        	$pee = preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+        	$pee = preg_replace('/<p>(<(?:table|[ou]l|pre|select|form|blockquote)>)/', "$1", $pee);
+        	$pee = preg_replace('!(</?(?:table|[ou]l|pre|select|form|blockquote)>)</p>!', "$1", $pee);
+        	if ($br) $pee = preg_replace('|(?<!</p>)\s*\n|', "<br />\n", $pee); // optionally make line breaks
+        	$pee = preg_replace('!(</(?:table|[ou]l|pre|select|form|blockquote)>)<br />!', "$1", $pee);
         	$pee = str_replace('<p><p>', '<p>', $pee);
         	$pee = str_replace('</p></p>', '</p>', $pee);
 
@@ -225,6 +224,7 @@
 		function htmlDecode( $htmlString, $quote_style = ENT_QUOTES )
 		{
             // replace numeric entities
+            // TODO: check these 
             $htmlString = my_preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $htmlString);
             $htmlString = my_preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $htmlString);
             // get the entity translation table from PHP (current encoding is ISO-8859-1)
@@ -277,9 +277,9 @@
 		      // put all the html entities back to what they should be
 		      $result = TextFilter::htmlDecode( $result );
 		      // and remove everything which is not letters or numbers
-		      $result = my_preg_replace( "/[^A-Za-z0-9_]/", " ", $result );
+		      $result = preg_replace( "/[^A-Za-z0-9_]/", " ", $result );
 		      // finally, remove the unnecessary spaces
-		      $result = my_preg_replace( "/ +/", " ", $result );
+		      $result = preg_replace( "/ +/", " ", $result );
 		      
 		      return $result;
 		}
@@ -314,7 +314,7 @@
             $nestable_tags = array('blockquote', 'div', 'span'); 
 
                 // WP bug fix for LOVE <3 (and other situations with '<' before a number)
-            $text = my_preg_replace('#<([0-9]{1})#', '<$1', $text);
+            $text = preg_replace('#<([0-9]{1})#', '<$1', $text);
 
             while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) {
                 $newtext .= $tagqueue;
@@ -419,7 +419,7 @@
             $separator = $config->getValue( "urlize_word_separator", URLIZE_WORD_SEPARATOR_DEFAULT );
 
             // remove unnecessary spaces and make everything lower case
-		    $string = my_preg_replace( "/ +/", " ", strtolower($string) );
+		    $string = preg_replace( "/ +/", " ", strtolower($string) );
 
             // removing a set of reserved characters (rfc2396: ; / ? : @ & = + $ ,)
             $string = str_replace(array(';','/','?',':','@','&','=','+','$',','),
@@ -443,15 +443,15 @@
             
                 // and everything that is still left that hasn't been
                 // replaced/encoded, throw it away
-                // NOTE: need double backslash to pass the escape to my_preg_replace
+                // NOTE: need double backslash to pass the escape to preg_replace
             $good_characters = "a-z0-9.\\".$separator;
             if(!$domainize){
                 $good_characters .= "_\\-";
             }
-            $string = my_preg_replace( '/[^'.$good_characters.']/', '', $string );        
+            $string = preg_replace( '/[^'.$good_characters.']/', '', $string );        
             
                 // remove doubled separators
-            $string = my_preg_replace("/[".$separator."]+/", $separator, $string);
+            $string = preg_replace("/[".$separator."]+/", $separator, $string);
                 // remove starting and trailing separator chars
             $string = trim($string, $separator);
             if($domainize){
@@ -536,9 +536,9 @@
                 $validChars = "_0-9a-zA-Z.-";
             }
                 // remove "bad" characters
-            $string = my_preg_replace("/[^".$validChars."]/", $separator, strip_tags(Textfilter::htmlDecode($string)));
+            $string = preg_replace("/[^".$validChars."]/", $separator, strip_tags(Textfilter::htmlDecode($string)));
                 // remove doubled separators
-            $string = my_preg_replace("/[".$separator."]+/", $separator, $string);
+            $string = preg_replace("/[".$separator."]+/", $separator, $string);
                 // remove starting and trailing separator chars
             $string = trim($string, $separator);
 				// and convert to lowercase



More information about the pLog-svn mailing list