Ignore:
Timestamp:
Jul 15, 2009, 1:41:41 PM (15 years ago)
Author:
patdenice
Message:

Update smarty to 2.6.26

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/smarty/libs/Smarty_Compiler.class.php

    r3001 r3583  
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020 *
    21  * @link http://www.smarty.net/
     21 * @link http://smarty.php.net/
    2222 * @author Monte Ohrt <monte at ohrt dot com>
    2323 * @author Andrei Zmievski <andrei@php.net>
    24  * @version 2.6.22
     24 * @version 2.6.26
    2525 * @copyright 2001-2005 New Digital Group, Inc.
    2626 * @package Smarty
    2727 */
    2828
    29 /* $Id: Smarty_Compiler.class.php 2966 2008-12-08 15:10:03Z monte.ohrt $ */
     29/* $Id: Smarty_Compiler.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
    3030
    3131/**
     
    7474    var $_strip_depth           =   0;
    7575    var $_additional_newline    =   "\n";
    76    
    77     var $_phpversion            =   0;
    78 
    7976
    8077    /**#@-*/
     
    8481    function Smarty_Compiler()
    8582    {
    86         $this->_phpversion = substr(phpversion(),0,1);
    87 
    8883        // matches double quoted strings:
    8984        // "foobar"
     
    158153        // $foo->bar($foo->bar())
    159154        // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar))
    160         // $foo->getBar()->getFoo()
    161         // $foo->getBar()->foo
    162155        $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
    163156        $this->_obj_restricted_param_regexp = '(?:'
    164              . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
    165              . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
    166 
    167        $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
     157                . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
     158                . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
     159        $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
    168160                . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)';
    169 
    170        $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
     161        $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
    171162                . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
    172        $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
    173        $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
     163        $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
     164        $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
    174165       
    175166        // matches valid modifier syntax:
     
    17061697        // replace double quoted literal string with single quotes
    17071698        $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return);
    1708         // escape dollar sign if not printing a var
    1709         $_return = preg_replace('~\$(\W)~',"\\\\\$\\1",$_return);
    17101699        return $_return;
    17111700    }
     
    17211710    {
    17221711        $_has_math = false;
    1723         $_has_php4_method_chaining = false;
    17241712        $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
    17251713
     
    18341822                        }
    18351823                    } else {
    1836                        if ($this->_phpversion < 5) {
    1837                          $_has_php4_method_chaining = true;
    1838                          $_output .= "; \$_foo = \$_foo";
    1839                        }
    18401824                        $_output .= $_index;
    18411825                    }
     
    18491833        }
    18501834
    1851         if ($_has_php4_method_chaining) {
    1852            $_tmp = str_replace("'","\'",'$_foo = '.$_output.'; return $_foo;');
    1853            return "eval('".$_tmp."')";
    1854         } else {
    1855            return $_output;
    1856         }
     1835        return $_output;
    18571836    }
    18581837
     
    20692048
    20702049            case 'get':
    2071                 $compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']";
     2050                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2051                    $this->_syntax_error("(secure mode) super global access not permitted",
     2052                                         E_USER_WARNING, __FILE__, __LINE__);
     2053                    return;
     2054                }
     2055                $compiled_ref = "\$_GET";
    20722056                break;
    20732057
    20742058            case 'post':
    2075                 $compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']";
     2059                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2060                    $this->_syntax_error("(secure mode) super global access not permitted",
     2061                                         E_USER_WARNING, __FILE__, __LINE__);
     2062                    return;
     2063                }
     2064                $compiled_ref = "\$_POST";
    20762065                break;
    20772066
    20782067            case 'cookies':
    2079                 $compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']";
     2068                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2069                    $this->_syntax_error("(secure mode) super global access not permitted",
     2070                                         E_USER_WARNING, __FILE__, __LINE__);
     2071                    return;
     2072                }
     2073                $compiled_ref = "\$_COOKIE";
    20802074                break;
    20812075
    20822076            case 'env':
    2083                 $compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']";
     2077                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2078                    $this->_syntax_error("(secure mode) super global access not permitted",
     2079                                         E_USER_WARNING, __FILE__, __LINE__);
     2080                    return;
     2081                }
     2082                $compiled_ref = "\$_ENV";
    20842083                break;
    20852084
    20862085            case 'server':
    2087                 $compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']";
     2086                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2087                    $this->_syntax_error("(secure mode) super global access not permitted",
     2088                                         E_USER_WARNING, __FILE__, __LINE__);
     2089                    return;
     2090                }
     2091                $compiled_ref = "\$_SERVER";
    20882092                break;
    20892093
    20902094            case 'session':
    2091                 $compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']";
     2095                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2096                    $this->_syntax_error("(secure mode) super global access not permitted",
     2097                                         E_USER_WARNING, __FILE__, __LINE__);
     2098                    return;
     2099                }
     2100                $compiled_ref = "\$_SESSION";
    20922101                break;
    20932102
     
    20972106             */
    20982107            case 'request':
     2108                if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
     2109                    $this->_syntax_error("(secure mode) super global access not permitted",
     2110                                         E_USER_WARNING, __FILE__, __LINE__);
     2111                    return;
     2112                }
    20992113                if ($this->request_use_auto_globals) {
    2100                     $compiled_ref = '$_REQUEST';
     2114                    $compiled_ref = "\$_REQUEST";
    21012115                    break;
    21022116                } else {
Note: See TracChangeset for help on using the changeset viewer.