mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-11 07:51:32 +02:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f25dd94f9f | ||
|
|
d1dcee0d9e | ||
|
|
8df47cf030 | ||
|
|
6f41b9bfc9 | ||
|
|
7d48d8692f | ||
|
|
ca2be225d6 | ||
|
|
3b0b48ed3e | ||
|
|
62dc42b0c5 | ||
|
|
818aa3c3da | ||
|
|
e12895359b |
@@ -12,6 +12,7 @@
|
|||||||
/.gitattributes export-ignore
|
/.gitattributes export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
|
/error_reporting.ini export-ignore
|
||||||
/make-release.sh export-ignore
|
/make-release.sh export-ignore
|
||||||
/phpunit.sh export-ignore
|
/phpunit.sh export-ignore
|
||||||
/phpunit.xml export-ignore
|
/phpunit.xml export-ignore
|
||||||
|
|||||||
@@ -6,45 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fixed illegal characters bug in math function security check [#702](https://github.com/smarty-php/smarty/issues/702)
|
|
||||||
|
|
||||||
## [3.1.43] - 2022-01-10
|
|
||||||
|
|
||||||
### Security
|
|
||||||
- Prevent evasion of the `static_classes` security policy. This addresses CVE-2021-21408
|
|
||||||
|
|
||||||
## [3.1.42] - 2022-01-10
|
|
||||||
|
|
||||||
### Security
|
|
||||||
- Prevent arbitrary PHP code execution through maliciously crafted expression for the math function. This addresses CVE-2021-29454
|
|
||||||
|
|
||||||
## [3.1.41] - 2022-01-09
|
|
||||||
|
|
||||||
### Security
|
|
||||||
- Rewrote the mailto function to not use `eval` when encoding with javascript
|
|
||||||
|
|
||||||
## [3.1.40] - 2021-10-13
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- modifier escape now triggers a E_USER_NOTICE when an unsupported escape type is used https://github.com/smarty-php/smarty/pull/649
|
|
||||||
|
|
||||||
### Security
|
|
||||||
- More advanced javascript escaping to handle https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements thanks to m-haritonov
|
|
||||||
|
|
||||||
## [3.1.39] - 2021-02-17
|
|
||||||
|
|
||||||
### Security
|
|
||||||
- Prevent access to `$smarty.template_object` in sandbox mode. This addresses CVE-2021-26119.
|
|
||||||
- Fixed code injection vulnerability by using illegal function names in `{function name='blah'}{/function}`. This addresses CVE-2021-26120.
|
|
||||||
|
|
||||||
## [3.1.38] - 2021-01-08
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Smarty::SMARTY_VERSION wasn't updated https://github.com/smarty-php/smarty/issues/628
|
|
||||||
|
|
||||||
## [3.1.37] - 2021-01-07
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
|
- Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
|
||||||
- Changed expected error levels in unit tests for php8-compatibility
|
- Changed expected error levels in unit tests for php8-compatibility
|
||||||
@@ -53,7 +14,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- PHP5.3 compatibility fixes
|
- PHP5.3 compatibility fixes
|
||||||
- Brought lexer source functionally up-to-date with compiled version
|
|
||||||
|
|
||||||
## [3.1.36] - 2020-04-14
|
## [3.1.36] - 2020-04-14
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Smarty: the PHP compiling template engine
|
|||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Smarty can be run with PHP 5.2 to PHP 7.4.
|
|||||||
|
|
||||||
> Read the NEW_FEATURES and INHERITANCE_RELEASE_NOTES file for recent extensions to Smarty 3.1 functionality
|
> Read the NEW_FEATURES and INHERITANCE_RELEASE_NOTES file for recent extensions to Smarty 3.1 functionality
|
||||||
|
|
||||||
Smarty versions 3.1.11 or later are now on GitHub and can be installed with Composer.
|
Smarty versions 3.1.11 or later are now on github and can be installed with Composer.
|
||||||
|
|
||||||
|
|
||||||
The "smarty/smarty" package will start at libs/.... subfolder.
|
The "smarty/smarty" package will start at libs/.... subfolder.
|
||||||
|
|||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.)
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 4.0.x | :white_check_mark: |
|
|
||||||
| 3.1.x | :white_check_mark: |
|
|
||||||
| < 3.1 | :x: |
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
If you have discovered a security issue with Smarty, please contact us at mail [at] simonwisselink.nl. Do not
|
|
||||||
disclose your findings publicly and PLEASE PLEASE do not file an Issue.
|
|
||||||
|
|
||||||
We will try to confirm the vulnerability and develop a fix if appropriate. When we release the fix, we will publish
|
|
||||||
a security release. Please let us know if you want to be credited.
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||||
@@ -249,13 +249,7 @@ template ::= template PHP(B). {
|
|||||||
|
|
||||||
// template text
|
// template text
|
||||||
template ::= template TEXT(B). {
|
template ::= template TEXT(B). {
|
||||||
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
|
$this->current_buffer->append_subtree($this, $this->compiler->processText(B));
|
||||||
|
|
||||||
if ((string)$text == '') {
|
|
||||||
$this->current_buffer->append_subtree($this, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text($text, $this->strip));
|
|
||||||
}
|
}
|
||||||
// strip on
|
// strip on
|
||||||
template ::= template STRIPON. {
|
template ::= template STRIPON. {
|
||||||
@@ -314,7 +308,7 @@ smartytag(A)::= SIMPLETAG(B). {
|
|||||||
$tag = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
|
$tag = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
|
||||||
if ($tag == 'strip') {
|
if ($tag == 'strip') {
|
||||||
$this->strip = true;
|
$this->strip = true;
|
||||||
A = null;
|
A = null;;
|
||||||
} else {
|
} else {
|
||||||
if (defined($tag)) {
|
if (defined($tag)) {
|
||||||
if ($this->security) {
|
if ($this->security) {
|
||||||
@@ -758,9 +752,6 @@ value(res) ::= doublequoted_with_quotes(s). {
|
|||||||
|
|
||||||
|
|
||||||
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
|
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
|
||||||
if ($this->security && $this->security->static_classes !== array()) {
|
|
||||||
$this->compiler->trigger_template_error('dynamic static class not allowed by security setting');
|
|
||||||
}
|
|
||||||
$prefixVar = $this->compiler->getNewPrefixVariable();
|
$prefixVar = $this->compiler->getNewPrefixVariable();
|
||||||
if (vi['var'] === '\'smarty\'') {
|
if (vi['var'] === '\'smarty\'') {
|
||||||
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
|
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
* @author Uwe Tews <uwe dot tews at gmail dot com>
|
* @author Uwe Tews <uwe dot tews at gmail dot com>
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
|
* @version 3.1.34-dev
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* set SMARTY_DIR to absolute path to Smarty library files.
|
* set SMARTY_DIR to absolute path to Smarty library files.
|
||||||
@@ -111,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.43';
|
const SMARTY_VERSION = '3.1.36';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
|||||||
@@ -94,19 +94,22 @@ function smarty_function_mailto($params)
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
|
||||||
if ($encode === 'javascript') {
|
if ($encode === 'javascript') {
|
||||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||||
$js_encode = '';
|
$js_encode = '';
|
||||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||||
$js_encode .= '%' . bin2hex($string[ $x ]);
|
$js_encode .= '%' . bin2hex($string[ $x ]);
|
||||||
}
|
}
|
||||||
return '<script type="text/javascript">document.write(unescape(\'' . $js_encode . '\'))</script>';
|
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
|
||||||
} elseif ($encode === 'javascript_charcode') {
|
} elseif ($encode === 'javascript_charcode') {
|
||||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
for ($x = 0, $y = strlen($string); $x < $y; $x++) {
|
||||||
$ord[] = ord($string[ $x ]);
|
$ord[] = ord($string[ $x ]);
|
||||||
}
|
}
|
||||||
return '<script type="text/javascript">document.write(String.fromCharCode(' . implode(',', $ord) . '))</script>';
|
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
|
||||||
|
implode(',', $ord) . "))" . "}\n" . "</script>\n";
|
||||||
|
return $_ret;
|
||||||
} elseif ($encode === 'hex') {
|
} elseif ($encode === 'hex') {
|
||||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||||
if (!empty($match[ 2 ])) {
|
if (!empty($match[ 2 ])) {
|
||||||
|
|||||||
@@ -28,12 +28,7 @@ function smarty_function_math($params, $template)
|
|||||||
'int' => true,
|
'int' => true,
|
||||||
'abs' => true,
|
'abs' => true,
|
||||||
'ceil' => true,
|
'ceil' => true,
|
||||||
'acos' => true,
|
|
||||||
'acosh' => true,
|
|
||||||
'cos' => true,
|
'cos' => true,
|
||||||
'cosh' => true,
|
|
||||||
'deg2rad' => true,
|
|
||||||
'rad2deg' => true,
|
|
||||||
'exp' => true,
|
'exp' => true,
|
||||||
'floor' => true,
|
'floor' => true,
|
||||||
'log' => true,
|
'log' => true,
|
||||||
@@ -44,51 +39,27 @@ function smarty_function_math($params, $template)
|
|||||||
'pow' => true,
|
'pow' => true,
|
||||||
'rand' => true,
|
'rand' => true,
|
||||||
'round' => true,
|
'round' => true,
|
||||||
'asin' => true,
|
|
||||||
'asinh' => true,
|
|
||||||
'sin' => true,
|
'sin' => true,
|
||||||
'sinh' => true,
|
|
||||||
'sqrt' => true,
|
'sqrt' => true,
|
||||||
'srand' => true,
|
'srand' => true,
|
||||||
'atan' => true,
|
'tan' => true
|
||||||
'atanh' => true,
|
|
||||||
'tan' => true,
|
|
||||||
'tanh' => true
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// be sure equation parameter is present
|
// be sure equation parameter is present
|
||||||
if (empty($params[ 'equation' ])) {
|
if (empty($params[ 'equation' ])) {
|
||||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$equation = $params[ 'equation' ];
|
$equation = $params[ 'equation' ];
|
||||||
|
|
||||||
// Remove whitespaces
|
|
||||||
$equation = preg_replace('/\s+/', '', $equation);
|
|
||||||
|
|
||||||
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
|
|
||||||
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
|
|
||||||
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
|
|
||||||
$operators = '[+\/*\^%-]'; // Allowed math operators
|
|
||||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
|
|
||||||
|
|
||||||
if (!preg_match($regexp, $equation)) {
|
|
||||||
trigger_error("math: illegal characters", E_USER_WARNING);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure parenthesis are balanced
|
// make sure parenthesis are balanced
|
||||||
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
||||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow backticks
|
// disallow backticks
|
||||||
if (strpos($equation, '`') !== false) {
|
if (strpos($equation, '`') !== false) {
|
||||||
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
|
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// also disallow dollar signs
|
// also disallow dollar signs
|
||||||
if (strpos($equation, '$') !== false) {
|
if (strpos($equation, '$') !== false) {
|
||||||
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
|
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
|
||||||
@@ -125,7 +96,6 @@ function smarty_function_math($params, $template)
|
|||||||
}
|
}
|
||||||
$smarty_math_result = null;
|
$smarty_math_result = null;
|
||||||
eval("\$smarty_math_result = " . $equation . ";");
|
eval("\$smarty_math_result = " . $equation . ";");
|
||||||
|
|
||||||
if (empty($params[ 'format' ])) {
|
if (empty($params[ 'format' ])) {
|
||||||
if (empty($params[ 'assign' ])) {
|
if (empty($params[ 'assign' ])) {
|
||||||
return $smarty_math_result;
|
return $smarty_math_result;
|
||||||
|
|||||||
@@ -184,11 +184,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
'"' => '\\"',
|
'"' => '\\"',
|
||||||
"\r" => '\\r',
|
"\r" => '\\r',
|
||||||
"\n" => '\\n',
|
"\n" => '\\n',
|
||||||
'</' => '<\/',
|
'</' => '<\/'
|
||||||
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
|
||||||
'<!--' => '<\!--',
|
|
||||||
'<s' => '<\s',
|
|
||||||
'<S' => '<\S'
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
case 'mail':
|
case 'mail':
|
||||||
@@ -254,7 +250,6 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
default:
|
default:
|
||||||
trigger_error("escape: unsupported type: $esc_type - returning unmodified string", E_USER_NOTICE);
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,10 +89,9 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||||
case 'javascript':
|
case 'javascript':
|
||||||
// escape quotes and backslashes, newlines, etc.
|
// escape quotes and backslashes, newlines, etc.
|
||||||
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
|
||||||
return 'strtr(' .
|
return 'strtr(' .
|
||||||
$params[ 0 ] .
|
$params[ 0 ] .
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||||
}
|
}
|
||||||
} catch (SmartyException $e) {
|
} catch (SmartyException $e) {
|
||||||
// pass through to regular plugin fallback
|
// pass through to regular plugin fallback
|
||||||
|
|||||||
@@ -58,11 +58,6 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
unset($_attr[ 'nocache' ]);
|
unset($_attr[ 'nocache' ]);
|
||||||
$_name = trim($_attr[ 'name' ], '\'"');
|
$_name = trim($_attr[ 'name' ], '\'"');
|
||||||
|
|
||||||
if (!preg_match('/^[a-zA-Z0-9_\x80-\xff]+$/', $_name)) {
|
|
||||||
$compiler->trigger_template_error("Function name contains invalid characters: {$_name}", null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
||||||
$save = array(
|
$save = array(
|
||||||
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
||||||
|
|||||||
@@ -81,10 +81,6 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
case 'template':
|
case 'template':
|
||||||
return 'basename($_smarty_tpl->source->filepath)';
|
return 'basename($_smarty_tpl->source->filepath)';
|
||||||
case 'template_object':
|
case 'template_object':
|
||||||
if (isset($compiler->smarty->security_policy)) {
|
|
||||||
$compiler->trigger_template_error("(secure mode) template_object not permitted");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return '$_smarty_tpl';
|
return '$_smarty_tpl';
|
||||||
case 'current_dir':
|
case 'current_dir':
|
||||||
return 'dirname($_smarty_tpl->source->filepath)';
|
return 'dirname($_smarty_tpl->source->filepath)';
|
||||||
@@ -98,9 +94,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
||||||
return "(defined('{$_index[1]}') ? constant('{$_index[1]}') : null)";
|
return "defined('{$_index[1]}') ? constant('{$_index[1]}') : null";
|
||||||
} else {
|
} else {
|
||||||
return "(defined({$_index[1]}) ? constant({$_index[1]}) : null)";
|
return "defined({$_index[1]}) ? constant({$_index[1]}) : null";
|
||||||
}
|
}
|
||||||
// no break
|
// no break
|
||||||
case 'config':
|
case 'config':
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
$this->smarty->_debug->start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
// init the lexer/parser to compile the config file
|
// init the lexer/parser to compile the config file
|
||||||
/* @var Smarty_Internal_ConfigFileLexer $this->lex */
|
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
||||||
$this->lex = new $this->lexer_class(
|
$this->lex = new $this->lexer_class(
|
||||||
str_replace(
|
str_replace(
|
||||||
array(
|
array(
|
||||||
@@ -127,7 +127,7 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
) . "\n",
|
) . "\n",
|
||||||
$this
|
$this
|
||||||
);
|
);
|
||||||
/* @var Smarty_Internal_ConfigFileParser $this->parser */
|
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
||||||
$this->parser = new $this->parser_class($this->lex, $this);
|
$this->parser = new $this->parser_class($this->lex, $this);
|
||||||
if (function_exists('mb_internal_encoding')
|
if (function_exists('mb_internal_encoding')
|
||||||
&& function_exists('ini_get')
|
&& function_exists('ini_get')
|
||||||
|
|||||||
@@ -2837,10 +2837,6 @@ class Smarty_Internal_Templateparser
|
|||||||
// line 765 "../smarty/lexer/smarty_internal_templateparser.y"
|
// line 765 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||||
public function yy_r95()
|
public function yy_r95()
|
||||||
{
|
{
|
||||||
if ($this->security && $this->security->static_classes !== array()) {
|
|
||||||
$this->compiler->trigger_template_error('dynamic static class not allowed by security setting');
|
|
||||||
}
|
|
||||||
|
|
||||||
$prefixVar = $this->compiler->getNewPrefixVariable();
|
$prefixVar = $this->compiler->getNewPrefixVariable();
|
||||||
if ($this->yystack[ $this->yyidx + -2 ]->minor[ 'var' ] === '\'smarty\'') {
|
if ($this->yystack[ $this->yyidx + -2 ]->minor[ 'var' ] === '\'smarty\'') {
|
||||||
$this->compiler->appendPrefixCode("<?php {$prefixVar} = " .
|
$this->compiler->appendPrefixCode("<?php {$prefixVar} = " .
|
||||||
|
|||||||
+3
-10
@@ -1,11 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ "$1" =~ ^3\.[0-9\.-rc]+$ ]]; then
|
printf 'Creating release %s\n' "$1"
|
||||||
printf 'Creating release %s\n' "$1"
|
|
||||||
else
|
|
||||||
echo "Invalid version number: $1. This script can only make v3.x.x releases."
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
git checkout -b "release/$1"
|
git checkout -b "release/$1"
|
||||||
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
|
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
|
||||||
@@ -14,13 +9,11 @@ sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" libs/S
|
|||||||
git add CHANGELOG.md libs/Smarty.class.php
|
git add CHANGELOG.md libs/Smarty.class.php
|
||||||
git commit -m "version bump"
|
git commit -m "version bump"
|
||||||
|
|
||||||
git checkout support/3.1
|
git checkout master
|
||||||
git pull
|
git pull
|
||||||
git merge --no-ff "release/$1"
|
git merge --no-ff "release/$1"
|
||||||
git branch -d "release/$1"
|
git branch -d "release/$1"
|
||||||
git tag -a "v$1" -m "Release $1"
|
git tag -a "v$1" -m "Release $1"
|
||||||
|
git push --follow-tags
|
||||||
|
|
||||||
printf 'Done creating release %s\n' "$1"
|
printf 'Done creating release %s\n' "$1"
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
printf 'Run `git push --follow-tags origin` to publish it.\n'
|
|
||||||
|
|||||||
@@ -339,10 +339,6 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
|||||||
$this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
|
$this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
|
||||||
$this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
|
$this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group slow
|
|
||||||
*/
|
|
||||||
public function testClearCacheExpired()
|
public function testClearCacheExpired()
|
||||||
{
|
{
|
||||||
$this->smarty->caching = true;
|
$this->smarty->caching = true;
|
||||||
@@ -403,7 +399,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
|||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName)
|
public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
|||||||
* test grandchild/child/parent dependency test2
|
* test grandchild/child/parent dependency test2
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_2()
|
public function testCompileBlockGrandChildMustCompile_021_2()
|
||||||
{
|
{
|
||||||
@@ -193,7 +193,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
|||||||
* test grandchild/child/parent dependency test4
|
* test grandchild/child/parent dependency test4
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_4()
|
public function testCompileBlockGrandChildMustCompile_021_4()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -298,38 +298,18 @@ class SecurityTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals('25', $this->smarty->fetch($tpl));
|
$this->assertEquals('25', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test not trusted PHP function
|
* test not trusted PHP function
|
||||||
* @expectedException SmartyException
|
* @expectedException SmartyException
|
||||||
* @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting
|
* @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting
|
||||||
*/
|
* @runInSeparateProcess
|
||||||
public function testNotTrustedStaticClass()
|
* @preserveGlobalState disabled
|
||||||
{
|
*/
|
||||||
$this->smarty->security_policy->static_classes = array('null');
|
public function testNotTrustedStaticClass()
|
||||||
$this->smarty->fetch('string:{mysecuritystaticclass::square(5)}');
|
{
|
||||||
}
|
$this->smarty->security_policy->static_classes = array('null');
|
||||||
|
$this->smarty->fetch('string:{mysecuritystaticclass::square(5)}');
|
||||||
/**
|
}
|
||||||
* test not trusted PHP function
|
|
||||||
* @expectedException SmartyException
|
|
||||||
* @expectedExceptionMessage dynamic static class not allowed by security setting
|
|
||||||
*/
|
|
||||||
public function testNotTrustedStaticClassEval()
|
|
||||||
{
|
|
||||||
$this->smarty->security_policy->static_classes = array('null');
|
|
||||||
$this->smarty->fetch('string:{$test = "mysecuritystaticclass"}{$test::square(5)}');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test not trusted PHP function
|
|
||||||
* @expectedException SmartyException
|
|
||||||
* @expectedExceptionMessage dynamic static class not allowed by security setting
|
|
||||||
*/
|
|
||||||
public function testNotTrustedStaticClassSmartyVar()
|
|
||||||
{
|
|
||||||
$this->smarty->security_policy->static_classes = array('null');
|
|
||||||
$this->smarty->fetch('string:{$smarty.template_object::square(5)}');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testChangedTrustedDirectory()
|
public function testChangedTrustedDirectory()
|
||||||
{
|
{
|
||||||
@@ -402,15 +382,6 @@ class SecurityTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->security_policy->trusted_uri = array();
|
$this->smarty->security_policy->trusted_uri = array();
|
||||||
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
|
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In security mode, accessing $smarty.template_object should be illegal.
|
|
||||||
* @expectedException SmartyCompilerException
|
|
||||||
*/
|
|
||||||
public function testSmartyTemplateObject() {
|
|
||||||
$this->smarty->display('string:{$smarty.template_object}');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class mysecuritystaticclass
|
class mysecuritystaticclass
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_2()
|
public function testCompileBlockGrandChildMustCompile_021_2()
|
||||||
{
|
{
|
||||||
@@ -645,7 +645,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_3()
|
public function testCompileBlockGrandChildMustCompile_021_3()
|
||||||
{
|
{
|
||||||
@@ -670,7 +670,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_32()
|
public function testCompileBlockGrandChildMustCompile_021_32()
|
||||||
{
|
{
|
||||||
@@ -692,7 +692,6 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_4()
|
public function testCompileBlockGrandChildMustCompile_021_4()
|
||||||
{
|
{
|
||||||
@@ -717,7 +716,6 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
|
||||||
*/
|
*/
|
||||||
public function testCompileBlockGrandChildMustCompile_021_42()
|
public function testCompileBlockGrandChildMustCompile_021_42()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -210,7 +210,6 @@ class CompileInsertTest extends PHPUnit_Smarty
|
|||||||
* test insert plugin caching 2
|
* test insert plugin caching 2
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @group slow
|
|
||||||
*/
|
*/
|
||||||
public function testInsertPluginCaching3_2()
|
public function testInsertPluginCaching3_2()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testEncodeJavascript()
|
public function testEncodeJavascript()
|
||||||
{
|
{
|
||||||
$result = '<script type="text/javascript">document.write(unescape(\'%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e\'))</script>';
|
$result = '<script type="text/javascript">eval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e%27%29%3b\'))</script>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
|
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
|
|||||||
public function testEncodeJavascriptWithoutMbstring()
|
public function testEncodeJavascriptWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = '<script type="text/javascript">document.write(unescape(\'%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e\'))</script>';
|
$result = '<script type="text/javascript">eval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e%27%29%3b\'))</script>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
|
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
@@ -70,7 +70,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testEncodeJavascriptCharcode()
|
public function testEncodeJavascriptCharcode()
|
||||||
{
|
{
|
||||||
$result = '<script type="text/javascript">document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))</script>';
|
$result = "<script type=\"text/javascript\" language=\"javascript\">\n{document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))}\n</script>\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
|
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
|
|||||||
public function testEncodeJavascriptCharcodeWithoutMbstring()
|
public function testEncodeJavascriptCharcodeWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = '<script type="text/javascript">document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))</script>';
|
$result = "<script type=\"text/javascript\" language=\"javascript\">\n{document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))}\n</script>\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
|
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
|
|||||||
@@ -431,14 +431,5 @@ class CompileFunctionTest extends PHPUnit_Smarty
|
|||||||
array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++),
|
array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++),
|
||||||
array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++),
|
array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test handling of function names that are a security risk
|
|
||||||
* @expectedException SmartyCompilerException
|
|
||||||
*/
|
|
||||||
public function testIllegalFunctionName() {
|
|
||||||
$this->smarty->fetch('string:{function name=\'rce(){};echo "hi";function \'}{/function}');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,6 @@ class MathTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMultipleOperators()
|
|
||||||
{
|
|
||||||
$this->smarty->disableSecurity();
|
|
||||||
$expected = "2 -- 2";
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$x = 5}{$y = 4}{math equation="x - y + 1" x=$x y=$y} -- {math equation="5 - 4 + 1"}');
|
|
||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSyntaxSin()
|
public function testSyntaxSin()
|
||||||
{
|
{
|
||||||
$this->smarty->disableSecurity();
|
$this->smarty->disableSecurity();
|
||||||
@@ -115,35 +107,4 @@ class MathTest extends PHPUnit_Smarty
|
|||||||
$tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}');
|
$tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}');
|
||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
|
||||||
public function testBackticksIllegal()
|
|
||||||
{
|
|
||||||
$expected = "22.00";
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="`ls` x * y" x=$x y=$y}');
|
|
||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
|
||||||
public function testDollarSignsIllegal()
|
|
||||||
{
|
|
||||||
$expected = "22.00";
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="$" x=$x y=$y}');
|
|
||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
|
||||||
public function testBracketsIllegal()
|
|
||||||
{
|
|
||||||
$expected = "I";
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$x = "0"}{$y = "1"}{math equation="((y/x).(x))[x]" x=$x y=$y}');
|
|
||||||
$this->assertEquals($expected, $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SmartyNowTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test {$smarty.now nocache}
|
* test {$smarty.now nocache}
|
||||||
* @group slow
|
*
|
||||||
*/
|
*/
|
||||||
public function testSmartyNowNocache() {
|
public function testSmartyNowNocache() {
|
||||||
$this->smarty->setCaching(true);
|
$this->smarty->setCaching(true);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class StreamVariableTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* test no existent stream variable
|
* test no existant stream variable
|
||||||
*/
|
*/
|
||||||
// public function testStreamVariable2()
|
// public function testStreamVariable2()
|
||||||
// {
|
// {
|
||||||
|
|||||||
Reference in New Issue
Block a user