主要集中在 upload/includes/cls_template.php 文件中:
1:line 300 :
原语句:
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改为:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
2:line 495:
原语句:
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改为:
$replacement = preg_replace_callback("/(\'\\$[^,]+)/" ,function($matcher){return stripslashes(trim($matcher[1],'\''));},var_export($t, true));
$out = "<?php \n" . '$k = ' . $replacement . ";\n";
3:line 554: //zuimoban.com 转载不带网址,木JJ
原语句:
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改为:
$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function ($matcher) { return '.'.str_replace('$','\$',$matcher[1]); }, $val);
4:line 1071:
原语句:
/* 将模板中所有library替换为链接 */
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
修改为:
1:line 300 :
原语句:
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改为:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
2:line 495:
原语句:
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改为:
$replacement = preg_replace_callback("/(\'\\$[^,]+)/" ,function($matcher){return stripslashes(trim($matcher[1],'\''));},var_export($t, true));
$out = "<?php \n" . '$k = ' . $replacement . ";\n";
3:line 554: //zuimoban.com 转载不带网址,木JJ
原语句:
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改为:
$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function ($matcher) { return '.'.str_replace('$','\$',$matcher[1]); }, $val);
4:line 1071:
原语句:
/* 将模板中所有library替换为链接 */
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
修改为:
$pattern
=
'/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s'
;
$replacement
=
function
(
$m
) {
return
'{include file='
.
strtolower
(
$m
[1]).
'}'
;};
$source
= preg_replace_callback(
$pattern
,
$replacement
,
$source
);
版权所有:《太阳花工作室》 => 《ecshop修饰符preg_replace/e不安全的几处改动》
本文地址:http://bg.artuion.com/代码/338.html
除非注明,文章均为 《太阳花工作室》 原创,欢迎转载!转载请注明本文地址,谢谢。