Don't use create_function() deprecated in PHP 7.2

pull/5890/head
Aleksander Machniak 7 years ago
parent 0c3af6b950
commit 169cbc8c13

@ -1472,16 +1472,23 @@ class rcube_ldap extends rcube_addressbook
if (strpos($templ, '(') !== false) { if (strpos($templ, '(') !== false) {
// replace {attr} placeholders with (escaped!) attribute values to be safely eval'd // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd
$code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals))); $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals)));
$fn = create_function('', "return ($code);"); $res = false;
if (!$fn) {
try {
$res = eval("return ($code);");
}
catch (ParseError $e) {
// ignore
}
if ($res === false) {
rcube::raise_error(array( rcube::raise_error(array(
'code' => 505, 'type' => 'php', 'code' => 505, 'file' => __FILE__, 'line' => __LINE__,
'file' => __FILE__, 'line' => __LINE__,
'message' => "Expression parse error on: ($code)"), true, false); 'message' => "Expression parse error on: ($code)"), true, false);
continue; continue;
} }
$attrs[$lf] = $fn(); $attrs[$lf] = $res;
} }
else { else {
// replace {attr} placeholders with concrete attribute values // replace {attr} placeholders with concrete attribute values

Loading…
Cancel
Save