From 169cbc8c13e95025954cfb9c4f4ad71eef5b8705 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 8 Jul 2017 16:12:58 +0200 Subject: [PATCH] Don't use create_function() deprecated in PHP 7.2 --- program/lib/Roundcube/rcube_ldap.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index e166df3b2..e1fbdb7bd 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -1472,16 +1472,23 @@ class rcube_ldap extends rcube_addressbook if (strpos($templ, '(') !== false) { // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals))); - $fn = create_function('', "return ($code);"); - if (!$fn) { + $res = false; + + try { + $res = eval("return ($code);"); + } + catch (ParseError $e) { + // ignore + } + + if ($res === false) { rcube::raise_error(array( - 'code' => 505, 'type' => 'php', - 'file' => __FILE__, 'line' => __LINE__, + 'code' => 505, 'file' => __FILE__, 'line' => __LINE__, 'message' => "Expression parse error on: ($code)"), true, false); continue; } - $attrs[$lf] = $fn(); + $attrs[$lf] = $res; } else { // replace {attr} placeholders with concrete attribute values