Compare commits

...

51 Commits

Author SHA1 Message Date
Simon Wisselink 99085d8dc6 Merge branch 'release/3.1.44' into support/3.1 2022-01-18 00:12:04 +01:00
Simon Wisselink eed1e07128 version bump 2022-01-18 00:12:03 +01:00
Simon Wisselink 208f881d06 Bugfix/702 (#709)
* fix(math): fix equation regexp

Fixes #702.
2022-01-18 00:10:25 +01:00
Simon Wisselink 273f7e00fe Merge branch 'release/3.1.43' into support/3.1 2022-01-10 10:52:40 +01:00
Simon Wisselink ce1ff003d7 version bump 2022-01-10 10:52:39 +01:00
Simon Wisselink 28519ca00f Merge pull request from GHSA-4h9c-v5vg-5m6m 2022-01-10 10:48:27 +01:00
Simon Wisselink b674cba13d Merge branch 'release/3.1.42' into support/3.1 2022-01-10 00:08:36 +01:00
Simon Wisselink a52a5b72ba version bump 2022-01-10 00:08:34 +01:00
Simon Wisselink 7ad97ad030 Merge pull request from GHSA-29gp-2c3m-3j6m
* Temporary fix. Waiting for CVE

* Add CVE
2022-01-10 00:07:57 +01:00
Simon Wisselink d8fa8c982f Fixed unit tests 2022-01-09 23:29:58 +01:00
Simon Wisselink de7e15d423 Merge branch 'release/3.1.41' into support/3.1 2022-01-09 23:21:20 +01:00
Simon Wisselink 1b6919da85 version bump 2022-01-09 23:21:19 +01:00
Simon Wisselink 457284283a Rewrote the mailto function to not use eval when encoding with javascript
(cherry picked from commit c7576eb1a1)
2022-01-09 23:18:17 +01:00
Simon Wisselink 9ffca4a093 Make make-release.sh safer by checking for version number. 2021-10-22 16:00:25 +02:00
Simon Wisselink 0c8a549603 Make make-release.sh safer by checking for version number. 2021-10-22 15:58:10 +02:00
Simon Wisselink 9d4f8309ed Merge branch 'release/3.1.40' 2021-10-13 12:04:31 +02:00
Simon Wisselink 7c4354e7b8 version bump 2021-10-13 12:04:29 +02:00
Simon Wisselink 770bc4aae2 Merge branch 'm-haritonov-escape' 2021-08-19 16:15:57 +02:00
Simon Wisselink 0ff7ba5ab6 Add changelog 2021-08-19 16:13:30 +02:00
Simon Wisselink 3b0fd82849 Merge branch 'escape' of https://github.com/m-haritonov/smarty into m-haritonov-escape 2021-08-19 15:26:27 +02:00
Ikko Ashimine 1a68b79b6c Update README.md (#668)
github -> GitHub
2021-08-18 23:23:36 +02:00
Michael Voříšek e3eabe0b96 Delete uninted file expectException (#664) 2021-05-25 21:18:07 +02:00
Simon Wisselink 4698dd9fb0 Changelog 2021-03-21 21:24:32 +01:00
David Goodwin 039043e5a2 Update modifier.escape.php (#649)
trigger a notice if an incorrect modifier was used (E.g.|escape:quotes vs |escape:quote).
2021-03-21 21:21:55 +01:00
Mihail Haritonov 9cde36e3bc plugins: escape: javascript escaping secure fix 2021-02-28 16:44:56 +03:00
Simon Wisselink 290aee6db3 Update CHANGELOG.md
Add CVE's
2021-02-21 22:23:45 +01:00
Simon Wisselink e2485fa45e Create SECURITY.md 2021-02-21 22:03:44 +01:00
Simon Wisselink e27da524f7 Merge branch 'release/3.1.39' 2021-02-17 22:57:51 +01:00
Simon Wisselink a21f59663c version bump 2021-02-17 22:57:50 +01:00
Simon Wisselink 3148d406a0 changelog 2021-02-17 22:57:33 +01:00
Simon Wisselink 4f634c0097 Merge branch 'bugfix/tplfunction_sandbox_escape' 2021-02-17 22:52:34 +01:00
Simon Wisselink c9272058d9 Merge branch 'bugfix/template_object_sandbox_escape' 2021-02-17 22:51:38 +01:00
Simon Wisselink e66e293a8a Do not push release automatically in make release script, to enable a chance to catch any errors. 2021-02-17 22:50:52 +01:00
Simon Wisselink 74cab5a56b updated changelog header to security 2021-02-17 22:30:35 +01:00
Simon Wisselink 8fc66e27a7 Cannot use in Smarty3 yet, revert to @expectedException 2021-02-01 10:33:00 +01:00
Simon Wisselink 2543174460 Cannot use in Smarty3 yet, revert to @expectedException 2021-02-01 10:31:20 +01:00
Simon Wisselink 288a54f6b0 Add unit test 2021-01-24 23:52:45 +01:00
Simon Wisselink 165f1bd4d2 Fixed Code injection vulnerability by using illegal function names 2021-01-24 23:44:07 +01:00
Simon Wisselink 6463519a6c Prevent access to .template_object when in security mode to prevent PHP code injection vulnerability 2021-01-24 23:13:26 +01:00
Simon Wisselink fedc127057 Mark tests that use sleep calls as slow, so we can ignore them when running unit tests in development 2021-01-16 23:01:15 +01:00
Ikko Ashimine 3af2df20a4 Fix typo in StreamVariableTest.php (#616)
existant -> existent
2021-01-08 17:28:33 +01:00
Simon Wisselink 63b3c0aed0 Merge branch 'release/3.1.38' 2021-01-08 15:05:42 +01:00
Simon Wisselink 2af2a07906 version bump 2021-01-08 15:05:40 +01:00
Simon Wisselink cb4254355e Removed unused error_reporting.ini file, updated version number in Smarty::SMARTY_VERSION, fixed inline phpdoc that caused an IDE error 2021-01-08 15:05:10 +01:00
Simon Wisselink f65e7ddd22 fixed changelog 2021-01-07 00:34:08 +01:00
Simon Wisselink 92e05d4f8d Brought lexer source functionally up-to-date with compiled version (#625)
Fixes #621
2021-01-07 00:26:28 +01:00
Simon Wisselink e2b28167f8 Clarify correct LGPL version.
Fixes #612
2021-01-05 22:23:13 +01:00
Libor M 820782cd80 const fix for usage with comparison operators (#618)
Fixes #609 #613
2021-01-05 22:07:44 +01:00
Simon Wisselink c295786e43 Fixes for php8.0.0beta3 (#608)
* Set $errcontext argument optional to support PHP 8

- Argument is optional and deprecated in PHP 7.2

* Getting ready for PHP8, handling changed error levels/handlers mostly

* php5 compat syntax

* Updated UndefinedTemplateVarTest for PHP8 (and disabled a check for PHP<5.6) and re-enabled php:nightly in travis config

* Attempt to fix travis runs for (almost) all php versions supported

* Fix unit tests for php8, force composer to think we are still php7 to pick a supported phpunit and being less specific about an error msg because PHP8 is in active development and the exact wording is changing.

* Fixed a unit test that accidentally passed on phpunit < 7 because of sloppy string comparison.

* changelog

* run travis in xenial where possible for latest php versions. Fix unit tests from freakingo over inconsistent error messages in php8-beta.

* Incorporated AnrDaemons suggestions, making composer figure out the required phpunit version instead of specifying it explicitly and removing a unneeded error supression (@).

Co-authored-by: Jorge Sá Pereira <me@jorgesapereira.com>
2020-09-12 21:37:31 +02:00
♚ PH⑦ de Soria™♛ 859a09e1bb Bumped phpdoc @version tag to 3.1.36 (#598)
Although this could be removed, since the header comment is still there, it's good to keep the @version tag updated in order to avoid confusion for those who read it :)
2020-09-11 13:34:15 +02:00
Simon Wisselink a5934a755d Fixed a unit test that accidentally passed on phpunit < 7 because of sloppy string comparison. 2020-09-11 13:22:45 +02:00
44 changed files with 334 additions and 103 deletions
-1
View File
@@ -12,7 +12,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/error_reporting.ini export-ignore
/make-release.sh export-ignore
/phpunit.sh export-ignore
/phpunit.xml export-ignore
+14 -13
View File
@@ -1,38 +1,39 @@
language: php
os: linux
dist: xenial
sudo: false
install:
- travis_retry composer install
dist: trusty
matrix:
jobs:
include:
- php: 5.3 # Composer requires PHP 5.3.2+ to run, so we cannot test below 5.3
- php: 5.3 # Composer and PHPUnit require PHP 5.3.2+ to run, so we cannot test below 5.3
dist: precise # PHP 5.3 is supported only on Precise.
- php: 5.4
dist: trusty # PHP 5.4 is supported only on Trusty.
- php: 5.5
dist: trusty # PHP 5.5 is supported only on Trusty.
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
# - php: nightly # PHP nightly build testing disabled because PHPUnit doesn't support PHP8 yet.
- php: nightly
install: travis_retry composer config platform.php 7.4.0 && composer install
fast_finish: true
allow_failures:
- php: nightly
- php: nightly # PHP 8 is still in beta
services:
- memcached
- mysql
before_script:
- mysql -e "create database IF NOT EXISTS test;" -uroot
- mysql -e "create database IF NOT EXISTS test;" -uroot
before_install:
- phpenv config-rm xdebug.ini || return 0
install:
- travis_retry composer install
- phpenv config-rm xdebug.ini || return 0
script:
- ./phpunit.sh
- ./phpunit.sh
+48 -3
View File
@@ -6,11 +6,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Travis unit tests now run for all php versions >= 5.3
## [3.1.44] - 2022-01-18
### Fixed
- PHP5.3 compatability fixes
- 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 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
- Travis unit tests now run for all php versions >= 5.3, including php8
- Travis runs on Xenial where possible
### Fixed
- PHP5.3 compatibility fixes
- Brought lexer source functionally up-to-date with compiled version
## [3.1.36] - 2020-04-14
+1 -1
View File
@@ -3,7 +3,7 @@ Smarty: the PHP compiling template engine
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
+1 -1
View File
@@ -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
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.
+19
View File
@@ -0,0 +1,19 @@
# 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.
+1 -1
View File
@@ -40,7 +40,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "6.4.1 || ^5.7 || ^4.8",
"phpunit/phpunit": "^7.5 || ^6.5 || ^5.7 || ^4.8",
"smarty/smarty-lexer": "^3.1"
}
}
-1
View File
@@ -1 +0,0 @@
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
+11 -2
View File
@@ -249,7 +249,13 @@ template ::= template PHP(B). {
// template text
template ::= template TEXT(B). {
$this->current_buffer->append_subtree($this, $this->compiler->processText(B));
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
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
template ::= template STRIPON. {
@@ -308,7 +314,7 @@ smartytag(A)::= SIMPLETAG(B). {
$tag = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
if ($tag == 'strip') {
$this->strip = true;
A = null;;
A = null;
} else {
if (defined($tag)) {
if ($this->security) {
@@ -752,6 +758,9 @@ value(res) ::= doublequoted_with_quotes(s). {
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();
if (vi['var'] === '\'smarty\'') {
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
+2 -3
View File
@@ -6,7 +6,7 @@
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +27,6 @@
* @author Uwe Tews <uwe dot tews at gmail dot com>
* @author Rodney Rehm
* @package Smarty
* @version 3.1.34-dev
*/
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@@ -112,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.36';
const SMARTY_VERSION = '3.1.44';
/**
* define variable scopes
*/
+1 -1
View File
@@ -6,7 +6,7 @@
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+4 -7
View File
@@ -94,22 +94,19 @@ function smarty_function_mailto($params)
);
return;
}
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
if ($encode === 'javascript') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
$js_encode = '';
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
$js_encode .= '%' . bin2hex($string[ $x ]);
}
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
return '<script type="text/javascript">document.write(unescape(\'' . $js_encode . '\'))</script>';
} elseif ($encode === 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
for ($x = 0, $y = strlen($string); $x < $y; $x++) {
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
$ord[] = ord($string[ $x ]);
}
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
implode(',', $ord) . "))" . "}\n" . "</script>\n";
return $_ret;
return '<script type="text/javascript">document.write(String.fromCharCode(' . implode(',', $ord) . '))</script>';
} elseif ($encode === 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[ 2 ])) {
+31 -1
View File
@@ -28,7 +28,12 @@ function smarty_function_math($params, $template)
'int' => true,
'abs' => true,
'ceil' => true,
'acos' => true,
'acosh' => true,
'cos' => true,
'cosh' => true,
'deg2rad' => true,
'rad2deg' => true,
'exp' => true,
'floor' => true,
'log' => true,
@@ -39,27 +44,51 @@ function smarty_function_math($params, $template)
'pow' => true,
'rand' => true,
'round' => true,
'asin' => true,
'asinh' => true,
'sin' => true,
'sinh' => true,
'sqrt' => true,
'srand' => true,
'tan' => true
'atan' => true,
'atanh' => true,
'tan' => true,
'tanh' => true
);
// be sure equation parameter is present
if (empty($params[ 'equation' ])) {
trigger_error("math: missing equation parameter", E_USER_WARNING);
return;
}
$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
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
return;
}
// disallow backticks
if (strpos($equation, '`') !== false) {
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
return;
}
// also disallow dollar signs
if (strpos($equation, '$') !== false) {
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
@@ -96,6 +125,7 @@ function smarty_function_math($params, $template)
}
$smarty_math_result = null;
eval("\$smarty_math_result = " . $equation . ";");
if (empty($params[ 'format' ])) {
if (empty($params[ 'assign' ])) {
return $smarty_math_result;
+6 -1
View File
@@ -184,7 +184,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
'"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/'
'</' => '<\/',
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
'<!--' => '<\!--',
'<s' => '<\s',
'<S' => '<\S'
)
);
case 'mail':
@@ -250,6 +254,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
}
return $return;
default:
trigger_error("escape: unsupported type: $esc_type - returning unmodified string", E_USER_NOTICE);
return $string;
}
}
+2 -1
View File
@@ -89,9 +89,10 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
case 'javascript':
// escape quotes and backslashes, newlines, etc.
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
return 'strtr(' .
$params[ 0 ] .
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
}
} catch (SmartyException $e) {
// pass through to regular plugin fallback
@@ -58,6 +58,11 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
}
unset($_attr[ 'nocache' ]);
$_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();
$save = array(
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
@@ -81,6 +81,10 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'template':
return 'basename($_smarty_tpl->source->filepath)';
case 'template_object':
if (isset($compiler->smarty->security_policy)) {
$compiler->trigger_template_error("(secure mode) template_object not permitted");
break;
}
return '$_smarty_tpl';
case 'current_dir':
return 'dirname($_smarty_tpl->source->filepath)';
@@ -94,9 +98,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
break;
}
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
return "@constant('{$_index[1]}')";
return "(defined('{$_index[1]}') ? constant('{$_index[1]}') : null)";
} else {
return "@constant({$_index[1]})";
return "(defined({$_index[1]}) ? constant({$_index[1]}) : null)";
}
// no break
case 'config':
@@ -115,7 +115,7 @@ class Smarty_Internal_Config_File_Compiler
$this->smarty->_debug->start_compile($this->template);
}
// 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(
str_replace(
array(
@@ -127,7 +127,7 @@ class Smarty_Internal_Config_File_Compiler
) . "\n",
$this
);
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
/* @var Smarty_Internal_ConfigFileParser $this->parser */
$this->parser = new $this->parser_class($this->lex, $this);
if (function_exists('mb_internal_encoding')
&& function_exists('ini_get')
@@ -65,7 +65,7 @@ class Smarty_Internal_ErrorHandler
*
* @return bool
*/
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = array())
{
$_is_muted_directory = false;
// add the SMARTY_DIR to the list of muted directories
@@ -2837,6 +2837,10 @@ class Smarty_Internal_Templateparser
// line 765 "../smarty/lexer/smarty_internal_templateparser.y"
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();
if ($this->yystack[ $this->yyidx + -2 ]->minor[ 'var' ] === '\'smarty\'') {
$this->compiler->appendPrefixCode("<?php {$prefixVar} = " .
+10 -3
View File
@@ -1,6 +1,11 @@
#!/bin/bash
printf 'Creating release %s\n' "$1"
if [[ "$1" =~ ^3\.[0-9\.-rc]+$ ]]; then
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"
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
@@ -9,11 +14,13 @@ sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" libs/S
git add CHANGELOG.md libs/Smarty.class.php
git commit -m "version bump"
git checkout master
git checkout support/3.1
git pull
git merge --no-ff "release/$1"
git branch -d "release/$1"
git tag -a "v$1" -m "Release $1"
git push --follow-tags
printf 'Done creating release %s\n' "$1"
# shellcheck disable=SC2016
printf 'Run `git push --follow-tags origin` to publish it.\n'
-1
View File
@@ -16,7 +16,6 @@ if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Frame
class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error_Error');
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning');
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Deprecated');
class_alias('\PHPUnit\Util\Configuration', '\PHPUnit_Util_Configuration');
}
require_once 'PHPUnit_Smarty.php';
@@ -24,34 +24,37 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
$this->cleanDirs();
}
/**
* Test E_NOTICE suppression template fetched by Smarty object
* Test Error suppression template fetched by Smarty object
*/
public function testE_NoticeDisabled()
public function testErrorDisabled()
{
$e1 = error_reporting();
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
$e2 = error_reporting();
$this->assertEquals($e1, $e2);
}
/**
* Test E_NOTICE suppression template fetched by template object
* Test Error suppression template fetched by template object
*/
public function testE_NoticeDisabledTplObject_1()
public function testErrorDisabledTplObject_1()
{
$e1 = error_reporting();
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('001_main.tpl');
$this->assertEquals('undefined = ', $tpl->fetch());
$e2 = error_reporting();
$this->assertEquals($e1, $e2);
}
public function testE_NoticeDisabledTplObject_2()
/**
* Test Error suppression template object fetched by Smarty object
*/
public function testErrorDisabledTplObject_2()
{
$e1 = error_reporting();
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('001_main.tpl');
$this->assertEquals('undefined = ', $this->smarty->fetch($tpl));
$e2 = error_reporting();
@@ -59,16 +62,31 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
}
/**
* Throw E_NOTICE message
*
* @expectedException PHPUnit_Framework_Error_Notice
* @expectedExceptionMessage Undefined index: foo
* Throw Error message
*/
public function testE_Notice()
public function testError()
{
$e1 = error_reporting();
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
$e2 = error_reporting();
$this->assertEquals($e1, $e2);
$exceptionThrown = false;
try {
$e1 = error_reporting();
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
$e2 = error_reporting();
$this->assertEquals($e1, $e2);
} catch (Exception $e) {
$exceptionThrown = true;
$this->assertStringStartsWith('Undefined ', $e->getMessage());
$this->assertTrue(in_array(
get_class($e),
array(
'PHPUnit_Framework_Error_Warning',
'PHPUnit_Framework_Error_Notice',
'PHPUnit\Framework\Error\Warning',
'PHPUnit\Framework\Error\Notice',
)
));
}
$this->assertTrue($exceptionThrown);
}
}
@@ -27,7 +27,7 @@ class MuteExpectedErrorsTest extends PHPUnit_Smarty
{
$this->cleanDirs();
}
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
{
$this->_errors[] = $errfile . ' line ' . $errline;
}
@@ -339,6 +339,10 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
$this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
}
/**
* @group slow
*/
public function testClearCacheExpired()
{
$this->smarty->caching = true;
@@ -399,7 +403,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider data
*
* @group slow
*/
public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName)
{
@@ -403,7 +403,11 @@ class ConfigVarTest extends PHPUnit_Smarty
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
}
catch (Exception $e) {
$this->assertEquals('Undefined variable: foo', $e->getMessage());
if (PHP_VERSION_ID >= 80000) {
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
} else {
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
}
}
}
}
@@ -125,7 +125,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
* test grandchild/child/parent dependency test2
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_2()
{
@@ -193,7 +193,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
* test grandchild/child/parent dependency test4
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_4()
{
+41 -12
View File
@@ -298,18 +298,38 @@ class SecurityTest extends PHPUnit_Smarty
$this->assertEquals('25', $this->smarty->fetch($tpl));
}
/**
* test not trusted PHP function
* @expectedException SmartyException
* @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testNotTrustedStaticClass()
{
$this->smarty->security_policy->static_classes = array('null');
$this->smarty->fetch('string:{mysecuritystaticclass::square(5)}');
}
/**
* test not trusted PHP function
* @expectedException SmartyException
* @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting
*/
public function testNotTrustedStaticClass()
{
$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()
{
@@ -382,6 +402,15 @@ class SecurityTest extends PHPUnit_Smarty
$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"}'));
}
/**
* In security mode, accessing $smarty.template_object should be illegal.
* @expectedException SmartyCompilerException
*/
public function testSmartyTemplateObject() {
$this->smarty->display('string:{$smarty.template_object}');
}
}
class mysecuritystaticclass
@@ -33,7 +33,7 @@ class ClearAllAssignBCTest extends PHPUnit_Smarty
public function testSmarty2ClearAllAssignInSmarty()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
error_reporting((error_reporting() & ~(E_NOTICE | E_WARNING | E_USER_NOTICE)));
$this->smartyBC->clear_all_assign();
$this->assertEquals('barblar', $this->smartyBC->fetch($this->_tplBC));
}
@@ -46,7 +46,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
*/
public function testClearAllAssignInTemplate()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
$this->_tpl->clearAllAssign();
$this->assertEquals('foobar', $this->smarty->fetch($this->_tpl));
}
@@ -56,7 +56,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
*/
public function testClearAllAssignInData()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
$this->_data->clearAllAssign();
$this->assertEquals('fooblar', $this->smarty->fetch($this->_tpl));
}
@@ -66,7 +66,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
*/
public function testClearAllAssignInSmarty()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
$this->smarty->clearAllAssign();
$this->assertEquals('barblar', $this->smarty->fetch($this->_tpl));
}
@@ -33,14 +33,14 @@ class ClearAssignBCTest extends PHPUnit_Smarty
}
public function testSmarty2ClearAssign()
{
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
$this->smartyBC->clear_assign('blar');
$this->assertEquals('foobar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}'));
}
public function testSmarty2ArrayClearAssign()
{
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
$this->smartyBC->clear_assign(array('blar', 'foo'));
$this->assertEquals('bar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}'));
}
@@ -36,7 +36,7 @@ class ClearAssignTest extends PHPUnit_Smarty
*/
public function testClearAssign()
{
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
$this->smarty->clearAssign('blar');
$this->assertEquals('foobar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}'));
}
@@ -46,7 +46,7 @@ class ClearAssignTest extends PHPUnit_Smarty
*/
public function testArrayClearAssign()
{
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
$this->smarty->clearAssign(array('blar', 'foo'));
$this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}'));
}
@@ -610,7 +610,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_2()
{
@@ -645,7 +645,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_3()
{
@@ -670,7 +670,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_32()
{
@@ -692,6 +692,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_4()
{
@@ -716,6 +717,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @group slow
*/
public function testCompileBlockGrandChildMustCompile_021_42()
{
@@ -44,7 +44,7 @@ class CompileForeachTest extends PHPUnit_Smarty
$this->smarty->assign('foo', $foo);
} else {
// unassigned $from parameter
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
}
$this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}");
@@ -210,6 +210,7 @@ class CompileInsertTest extends PHPUnit_Smarty
* test insert plugin caching 2
* @runInSeparateProcess
* @preserveGlobalState disabled
* @group slow
*/
public function testInsertPluginCaching3_2()
{
@@ -275,7 +275,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
protected $_errors = array();
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
{
$this->_errors[] = $errstr;
}
@@ -369,7 +369,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
protected $_errors = array();
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
{
$this->_errors[] = $errstr;
}
@@ -275,7 +275,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
protected $_errors = array();
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
{
$this->_errors[] = $errstr;
}
@@ -54,7 +54,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
public function testEncodeJavascript()
{
$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>';
$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>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
@@ -62,7 +62,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
public function testEncodeJavascriptWithoutMbstring()
{
Smarty::$_MBSTRING = false;
$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>';
$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>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
Smarty::$_MBSTRING = true;
@@ -70,7 +70,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
public function testEncodeJavascriptCharcode()
{
$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";
$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>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
@@ -78,7 +78,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
public function testEncodeJavascriptCharcodeWithoutMbstring()
{
Smarty::$_MBSTRING = false;
$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";
$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>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
Smarty::$_MBSTRING = true;
@@ -297,7 +297,7 @@ class CompileFunctionTest extends PHPUnit_Smarty
*/
public function testExternalDefinedFunctionRecursion($text)
{
$this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text);
$this->assertEquals('012345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text);
}
/**
@@ -431,5 +431,14 @@ 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\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}');
}
}
@@ -78,11 +78,13 @@ class ConstantsTest extends PHPUnit_Smarty
}
public function testConstantsUndefined()
{
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}');
$this->assertEquals("", $this->smarty->fetch($tpl));
}
public function testConstantsUndefined2()
{
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}');
$this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl));
}
@@ -44,6 +44,14 @@ class MathTest extends PHPUnit_Smarty
$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()
{
$this->smarty->disableSecurity();
@@ -107,4 +115,35 @@ 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"}');
$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}
*
* @group slow
*/
public function testSmartyNowNocache() {
$this->smarty->setCaching(true);
@@ -59,7 +59,7 @@ class StreamVariableTest extends PHPUnit_Smarty
}
*/
/**
* test no existant stream variable
* test no existent stream variable
*/
// public function testStreamVariable2()
// {