[pLog-svn] r7243 - in plog/branches/lifetype-1.2/class: data mail/phpmailer
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed Jul 15 07:36:52 EDT 2020
Author: jondaley
Date: 2020-07-15 07:36:52 -0400 (Wed, 15 Jul 2020)
New Revision: 7243
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/preg_wrapper.php
plog/branches/lifetype-1.2/class/data/textfilter.class.php
plog/branches/lifetype-1.2/class/mail/phpmailer/class.phpmailer.php
Log:
found a few more eval'ed preg_replace() calls. I think that is all of them. in the end, we didn't actually need the given my_preg_replace wrapper, as long as all eval'ed regexps manually call preg_replace_callback, and that is a lot more straightforward, I think
Modified: plog/branches/lifetype-1.2/class/data/inputfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/inputfilter.class.php 2020-07-15 11:17:56 UTC (rev 7242)
+++ plog/branches/lifetype-1.2/class/data/inputfilter.class.php 2020-07-15 11:36:52 UTC (rev 7243)
@@ -10,7 +10,6 @@
* @email: dan at rootcube.com
* @license: GNU General Public License (GPL)
*/
-lt_include( PLOG_CLASS_PATH."class/data/preg_wrapper.php" );
class InputFilter {
var $tagsArray; // default = empty array
@@ -266,8 +265,8 @@
// 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
+ $source = preg_replace_callback('/&#(\d+);/m',
+ function($m) { return chr($m[1]); }, $source); // decimal notation
// convert hex
$source = preg_replace_callback(
'/&#x([a-f0-9]+);/mi',
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:17:56 UTC (rev 7242)
+++ plog/branches/lifetype-1.2/class/data/kses.class.php 2020-07-15 11:36:52 UTC (rev 7243)
@@ -48,8 +48,6 @@
* Email: View current valid email address at http://www.chaos.org/contact/
*/
- lt_include( PLOG_CLASS_PATH."class/data/preg_wrapper.php" );
-
class kses
{
var $allowed_protocols = array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'mailto', 'irc', 'mms' );
Modified: plog/branches/lifetype-1.2/class/data/preg_wrapper.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/preg_wrapper.php 2020-07-15 11:17:56 UTC (rev 7242)
+++ plog/branches/lifetype-1.2/class/data/preg_wrapper.php 2020-07-15 11:36:52 UTC (rev 7243)
@@ -1,5 +1,6 @@
<?php
+// PHP5 compatbility
if (!function_exists('preg_replace_callback_array')) {
function preg_replace_callback_array (array $patterns_and_callbacks, $subject, $limit=-1, &$count=NULL) {
@@ -11,73 +12,3 @@
return preg_last_error() == PREG_NO_ERROR ? $subject : NULL;
}
}
-
-
-function is_evaled_preg($str)
-{
- if (!preg_match('~([a-z]+)$~i', $str, $ext))
- return false;
- $matched = $ext[1];
- if (strpos($matched, "e") === false)
- return false;
- $str = substr($str, 0, strlen($str) - strlen($matched));
- $matched = str_replace('e', '', $matched);
- return $str . $matched;
-}
-
-$lwb_compiled_regexes = array();
-
-function my_compile_regex($replacement)
-{
- global $lwb_compiled_regexes;
- $replacement = preg_replace_callback('~[\\$\\\\](\d+)~', function ($m)
- {
- return '$m[' . $m[1] . ']';
- }, $replacement);
- $replacement = str_replace('\\\\', '\\', $replacement);
- $replacement="return $replacement;";
- $ret = create_function('$m', $replacement);
- $lwb_compiled_regexes[$replacement] = $ret;
- return $ret;
-}
-
-function my_preg_replace_internal($pattern, $replacement, $subject)
-{
- global $lwb_compiled_regexes;
- $func = isset($lwb_compiled_regexes[$replacement]) ? $lwb_compiled_regexes[$replacement] : my_compile_regex($replacement);
- return preg_replace_callback($pattern, $func, $subject);
-}
-
-function my_preg_replace($pattern, $replacement, $subject)
-{
- if (!is_array($pattern))
- {
- $pattern = (array) $pattern;
- $replacement = (array) $replacement;
- }
-
- $pattern_out = array(
- 0 => array(),
- 1 => array()
- );
-
- $replacement_out = array(
- 0 => array(),
- 1 => array()
- );
-
- foreach ($pattern as $k => $p)
- {
- $is = is_evaled_preg($p);
- $ind = (int) (bool) $is;
- $pattern_out[$ind][] = $is ?: $p;
- $replacement_out[$ind][] = $replacement[$k];
- }
- if (count($pattern_out[0]))
- $subject = preg_replace($pattern_out[0], $replacement_out[0], $subject);
-
- foreach ($pattern_out[1] as $k => $p)
- $subject = my_preg_replace_internal($pattern_out[1][$k], $replacement_out[1][$k], $subject);
-
- return $subject;
-}
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:17:56 UTC (rev 7242)
+++ plog/branches/lifetype-1.2/class/data/textfilter.class.php 2020-07-15 11:36:52 UTC (rev 7243)
@@ -9,7 +9,6 @@
lt_include( PLOG_CLASS_PATH."class/data/stringutils.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/preg_wrapper.php" );
/**
* default character used as the word separator, instead of blank spaces
Modified: plog/branches/lifetype-1.2/class/mail/phpmailer/class.phpmailer.php
===================================================================
--- plog/branches/lifetype-1.2/class/mail/phpmailer/class.phpmailer.php 2020-07-15 11:17:56 UTC (rev 7242)
+++ plog/branches/lifetype-1.2/class/mail/phpmailer/class.phpmailer.php 2020-07-15 11:36:52 UTC (rev 7243)
@@ -1193,11 +1193,11 @@
$encoded .= $this->LE;
// Replace every high ascii, control and = characters
- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ $encoded = preg_replace_calllback('/([\000-\010\013\014\016-\037\075\177-\377])/',
+ function($m){ return '='.sprintf('%02X', ord($m[1])); }, $encoded);
// Replace every spaces and tabs when it's the last character on a line
- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
+ $encoded = preg_replace_callback("/([\011\040])".$this->LE."/",
+ function($m){ return '='.sprintf('%02X', ord($m[1])).$this->LE; }, $encoded);
// Maximum line length of 76 characters before CRLF (74 + space + '=')
$encoded = $this->WrapText($encoded, 74, true);
@@ -1216,15 +1216,17 @@
switch (strtolower($position)) {
case "phrase":
- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ $encoded = preg_replace_callback("/([^A-Za-z0-9!*+\/ -])/",
+ function($m){ return '='.sprintf('%02X', ord($m[1])); }, $encoded);
break;
case "comment":
- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ $encoded = preg_replace_callback("/([\(\)\"])/",
+ function($m){ return '='.sprintf('%02X', ord($m[1])); }, $encoded);
case "text":
default:
// Replace every high ascii, control =, ? and _ characters
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ $encoded = preg_replace_callback('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
+ function($m){ return '='.sprintf('%02X', ord($m[1])); }, $encoded);
break;
}
More information about the pLog-svn
mailing list