Thomas Bruederli
2013-05-01 2d6dca47146d33be703cacc85cb76b28cfca8aff
Escape user input values when used in eval()
1 files modified
16 ■■■■■ changed files
program/lib/Roundcube/rcube_ldap.php 16 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_ldap.php
@@ -1403,13 +1403,15 @@
        foreach ((array)$this->prop['autovalues'] as $lf => $templ) {
            if (empty($attrs[$lf])) {
                // replace {attr} placeholders with concrete attribute values
                $templ = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
                if (strpos($templ, '(') !== false)
                    $attrs[$lf] = eval("return ($templ);");
                else
                    $attrs[$lf] = $templ;
                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)));
                    $attrs[$lf] = eval("return ($code);");
                }
                else {
                    // replace {attr} placeholders with concrete attribute values
                    $attrs[$lf] = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
                }
            }
        }
    }