mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 12:34:33 +02:00
Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f3a11b374 | |||
| b2630915d6 | |||
| 273f7e00fe | |||
| ce1ff003d7 | |||
| 28519ca00f | |||
| b674cba13d | |||
| a52a5b72ba | |||
| 7ad97ad030 | |||
| d8fa8c982f | |||
| de7e15d423 | |||
| 1b6919da85 | |||
| 457284283a | |||
| 9ffca4a093 | |||
| 0c8a549603 | |||
| 9d4f8309ed | |||
| 7c4354e7b8 | |||
| 770bc4aae2 | |||
| 0ff7ba5ab6 | |||
| 3b0fd82849 | |||
| 1a68b79b6c | |||
| e3eabe0b96 | |||
| 4698dd9fb0 | |||
| 039043e5a2 | |||
| 9cde36e3bc | |||
| 290aee6db3 | |||
| e2485fa45e | |||
| e27da524f7 | |||
| a21f59663c | |||
| 3148d406a0 | |||
| 4f634c0097 | |||
| c9272058d9 | |||
| e66e293a8a | |||
| 74cab5a56b | |||
| 8fc66e27a7 | |||
| 2543174460 | |||
| 288a54f6b0 | |||
| 165f1bd4d2 | |||
| 6463519a6c | |||
| fedc127057 | |||
| 3af2df20a4 | |||
| 63b3c0aed0 | |||
| 2af2a07906 | |||
| cb4254355e | |||
| f65e7ddd22 | |||
| 92e05d4f8d | |||
| e2b28167f8 | |||
| 820782cd80 | |||
| c295786e43 | |||
| 859a09e1bb | |||
| a5934a755d | |||
| 5a72624380 | |||
| 1418c8c422 | |||
| f46c13b32a | |||
| eae19f23b9 | |||
| e1c050a32c | |||
| fd148f7ade | |||
| 07772aac90 | |||
| 08227651fc | |||
| e0ea6899c8 | |||
| 97f700971f | |||
| a0abc47588 | |||
| 728a584ad5 | |||
| 290f7cfc3d | |||
| 48d24b7ad1 | |||
| 19ef8342aa | |||
| 4f89f6d84f |
+10
-7
@@ -6,11 +6,14 @@
|
||||
*.lex text eol=lf
|
||||
|
||||
# exclude from git export
|
||||
/travis.ini export-ignore
|
||||
/myconfig.ini export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/.gitignore export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/lexer/ export-ignore
|
||||
/tests export-ignore
|
||||
/utilities/ export-ignore
|
||||
/error_reporting.ini export-ignore
|
||||
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/make-release.sh export-ignore
|
||||
/phpunit.sh export-ignore
|
||||
/phpunit.xml export-ignore
|
||||
/TODO.md export-ignore
|
||||
/travis.ini export-ignore
|
||||
|
||||
+17
-12
@@ -1,34 +1,39 @@
|
||||
|
||||
language: php
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
sudo: false
|
||||
install:
|
||||
- travis_retry composer install
|
||||
|
||||
dist: trusty
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
include:
|
||||
- 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
|
||||
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
|
||||
|
||||
+122
-54
@@ -1,7 +1,74 @@
|
||||
- fix foreachelse on arrayiterators https://github.com/smarty-php/smarty/issues/506
|
||||
- fix errors that occured where isset was replaced with null check such as https://github.com/smarty-php/smarty/issues/453
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
===== 3.1.34 release ===== 05.11.2019
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [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 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
|
||||
|
||||
### Fixed
|
||||
- Smarty::SMARTY_VERSION wasn't updated in v3.1.35 https://github.com/smarty-php/smarty/issues/584
|
||||
|
||||
## [3.1.35] - 2020-04-14
|
||||
- remove whitespaces after comments https://github.com/smarty-php/smarty/issues/447
|
||||
- fix foreachelse on arrayiterators https://github.com/smarty-php/smarty/issues/506
|
||||
- fix files contained in git export archive for package maintainers https://github.com/smarty-php/smarty/issues/325
|
||||
- throw SmartyException when setting caching attributes for cacheable plugin https://github.com/smarty-php/smarty/issues/457
|
||||
- fix errors that occured where isset was replaced with null check such as https://github.com/smarty-php/smarty/issues/453
|
||||
- unit tests are now in the repository
|
||||
|
||||
## 3.1.34 release - 05.11.2019
|
||||
13.01.2020
|
||||
- fix typo in exception message (JercSi)
|
||||
- fix typehint warning with callable (bets4breakfast)
|
||||
@@ -10,7 +77,8 @@
|
||||
- fix wrong set/get methods for memcached (IT-Experte)
|
||||
- fix pborm assigning value to object variables in smarty_internal_compile_assign (Hunman)
|
||||
- exclude error_reporting.ini from git export (glensc)
|
||||
===== 3.1.34-dev-6 =====
|
||||
|
||||
## 3.1.34-dev-6 -
|
||||
30.10.2018
|
||||
- bugfix a nested subblock in an inheritance child template was not replace by
|
||||
outer level block with same name in same child template https://github.com/smarty-php/smarty/issues/500
|
||||
@@ -38,8 +106,8 @@
|
||||
could fail in version 3.1.32 and 3.1.33 because PHP preg_match() restrictions
|
||||
https://github.com/smarty-php/smarty/issues/488
|
||||
|
||||
===== 3.1.33 release ===== 12.09.2018
|
||||
===== 3.1.33-dev-12 =====
|
||||
## 3.1.33 release - 12.09.2018
|
||||
## 3.1.33-dev-12 -
|
||||
03.09.2018
|
||||
- bugfix {foreach} using new style property access like {$item@property} on
|
||||
Smarty 2 style named foreach loop could produce errors https://github.com/smarty-php/smarty/issues/484
|
||||
@@ -61,14 +129,14 @@
|
||||
- bugfix/enhancement {capture} allow variable as capture block name in Smarty special variable
|
||||
like $smarty.capture.$foo https://github.com/smarty-php/smarty/issues/478 https://github.com/smarty-php/smarty/pull/481
|
||||
|
||||
===== 3.1.33-dev-6 =====
|
||||
## 3.1.33-dev-6 -
|
||||
19.08.2018
|
||||
- fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452
|
||||
https://github.com/smarty-php/smarty/pull/475
|
||||
https://github.com/smarty-php/smarty/pull/473
|
||||
- bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472
|
||||
|
||||
===== 3.1.33-dev-4 =====
|
||||
## 3.1.33-dev-4 -
|
||||
17.05.2018
|
||||
- bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436
|
||||
- bugfix Smarty::compileAllTemplates ignores `$extension` parameter https://github.com/smarty-php/smarty/issues/437
|
||||
@@ -80,7 +148,7 @@
|
||||
- bugfix regarding Security Vulnerability did not solve the problem under Linux.
|
||||
Security issue CVE-2018-16831
|
||||
|
||||
===== 3.1.32 ===== (24.04.2018)
|
||||
## 3.1.32 - (24.04.2018)
|
||||
24.04.2018
|
||||
- bugfix possible Security Vulnerability in Smarty_Security class.
|
||||
|
||||
@@ -221,7 +289,7 @@
|
||||
13.4.2017
|
||||
- bugfix array_merge() parameter should be checked https://github.com/smarty-php/smarty/issues/350
|
||||
|
||||
===== 3.1.31 ===== (14.12.2016)
|
||||
## 3.1.31 - (14.12.2016)
|
||||
23.11.2016
|
||||
- move template object cache into static variables
|
||||
|
||||
@@ -335,7 +403,7 @@
|
||||
compiled or cached template files https://github.com/smarty-php/smarty/issues/269
|
||||
- optimization remove unneeded call to update acopes when {assign} scope and template scope was local (default)
|
||||
|
||||
===== 3.1.30 ===== (07.08.2016)
|
||||
## 3.1.30 - (07.08.2016)
|
||||
|
||||
07.08.2016
|
||||
- bugfix update of 04.08.2016 was incomplete
|
||||
@@ -558,7 +626,7 @@
|
||||
- optimization of filepath normalization
|
||||
- bugfix {strip} must remove all blanks between html tags https://github.com/smarty-php/smarty/issues/136
|
||||
|
||||
===== 3.1.29 ===== (21.12.2015)
|
||||
- 3.1.29 - (21.12.2015)
|
||||
21.12.2015
|
||||
- optimization improve speed of filetime checks on extends and extendsall resource
|
||||
|
||||
@@ -594,7 +662,7 @@
|
||||
- bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120
|
||||
- bugfix multiple calls of {section} with same name droped E_NOTICE error https://github.com/smarty-php/smarty/issues/118
|
||||
|
||||
===== 3.1.28 ===== (13.12.2015)
|
||||
- 3.1.28 - (13.12.2015)
|
||||
13.12.2015
|
||||
- bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819)
|
||||
- bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811)
|
||||
@@ -773,18 +841,18 @@
|
||||
19.06.2015
|
||||
- improvement allow closures as callback at $smarty->registerFilter() https://github.com/smarty-php/smarty/issues/59
|
||||
|
||||
===== 3.1.27===== (18.06.2015)
|
||||
- 3.1.27- (18.06.2015)
|
||||
18.06.2015
|
||||
- bugfix another update on file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
|
||||
|
||||
===== 3.1.26===== (18.06.2015)
|
||||
- 3.1.26- (18.06.2015)
|
||||
18.06.2015
|
||||
- bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
|
||||
|
||||
17.06.2015
|
||||
- bugfix calling a plugin with nocache option but no other attributes like {foo nocache} caused call to undefined function https://github.com/smarty-php/smarty/issues/55
|
||||
|
||||
===== 3.1.25===== (15.06.2015)
|
||||
- 3.1.25- (15.06.2015)
|
||||
15.06.2015
|
||||
- optimization of smarty_cachereource_keyvaluestore.php code
|
||||
|
||||
@@ -814,7 +882,7 @@
|
||||
24.05.2015
|
||||
- bugfix if condition string 'neq' broken due to a typo https://github.com/smarty-php/smarty/issues/42
|
||||
|
||||
===== 3.1.24===== (23.05.2015)
|
||||
- 3.1.24- (23.05.2015)
|
||||
23.05.2015
|
||||
- improvement on php_handling to allow very large PHP sections, better error handling
|
||||
- improvement allow extreme large comment sections (forum 25538)
|
||||
@@ -852,12 +920,12 @@
|
||||
- bugfix access to undefined config variable like {#undef#} did fail https://github.com/smarty-php/smarty/issues/29
|
||||
- bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33
|
||||
|
||||
===== 3.1.23 ===== (12.05.2015)
|
||||
- 3.1.23 - (12.05.2015)
|
||||
12.05.2015
|
||||
- bugfix of smaller performance issue introduce in 3.1.22 when caching is enabled
|
||||
- bugfix missig entry for smarty-temmplate-config in autoloader
|
||||
|
||||
===== 3.1.22 ===== tag was deleted because 3.1.22 did fail caused by the missing entry for smarty-temmplate-config in autoloader
|
||||
- 3.1.22 - tag was deleted because 3.1.22 did fail caused by the missing entry for smarty-temmplate-config in autoloader
|
||||
10.05.2015
|
||||
- bugfix custom cache resource did not observe compile_id and cache_id when $cache_locking == true
|
||||
- bugfix cache lock was not handled correctly after timeout when $cache_locking == true
|
||||
@@ -1009,7 +1077,7 @@
|
||||
- bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text
|
||||
- bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached
|
||||
|
||||
===== 3.1.21 ===== (18.10.2014)
|
||||
- 3.1.21 - (18.10.2014)
|
||||
18.10.2014
|
||||
- composer moved to github
|
||||
|
||||
@@ -1032,7 +1100,7 @@
|
||||
- bugfix change of 08.10.2014 could create E_NOTICE meassage when using "<?php" tags
|
||||
- bugfix "<script language=php>" with $php_handling PHP_PASSTHRU was executed in {nocache} sections
|
||||
|
||||
===== 3.1.20 ===== (09.10.2014)
|
||||
- 3.1.20 - (09.10.2014)
|
||||
08.10.2014
|
||||
- bugfix security mode of "<script language=php>" must be controlled by $php_handling property (Thue Kristensen)
|
||||
|
||||
@@ -1052,7 +1120,7 @@
|
||||
04.07.2014
|
||||
- bugfix the bufix of 02.06.2014 broke correct handling of child templates with same name but different template folders in extends resource (issue 194 and topic 25099)
|
||||
|
||||
===== 3.1.19 ===== (30.06.2014)
|
||||
- 3.1.19 - (30.06.2014)
|
||||
20.06.2014
|
||||
- bugfix template variables could not be passed as parameter in {include} when the include was in a {nocache} section (topic 25131)
|
||||
|
||||
@@ -1079,7 +1147,7 @@
|
||||
18.04.2014
|
||||
- revert bugfix of 5.4.2014 because %-e date format is not supported on all operating systems
|
||||
|
||||
===== 3.1.18 ===== (07.04.2014)
|
||||
- 3.1.18 - (07.04.2014)
|
||||
06.04.2014
|
||||
- bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187)
|
||||
- bugfix update of composer file (Issue 168 and 184)
|
||||
@@ -1108,7 +1176,7 @@
|
||||
13.03.2014
|
||||
- bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867)
|
||||
|
||||
===== 3.1.17 =====
|
||||
- 3.1.17 -
|
||||
08.03.2014
|
||||
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
|
||||
|
||||
@@ -1139,7 +1207,7 @@
|
||||
- bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169)
|
||||
- bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683)
|
||||
|
||||
===== 3.1.16 =====
|
||||
- 3.1.16 -
|
||||
15.12.2013
|
||||
- bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
|
||||
Read 3.1.16_RELEASE_NOTES for more details
|
||||
@@ -1172,7 +1240,7 @@
|
||||
03.10.2013
|
||||
- bugfix loops using modifier capitalize did eat up memory (issue 159)
|
||||
|
||||
===== Smarty 3.1.15 =====
|
||||
- Smarty 3.1.15 -
|
||||
01.10.2013
|
||||
- use current delimiters in compiler error messages (issue 157)
|
||||
- improvement on performance when using error handler and multiple template folders (issue 152)
|
||||
@@ -1236,7 +1304,7 @@
|
||||
2.7.2013
|
||||
- bugfix trimwhitespace would replace captured items in wrong order (forum topic 24387)
|
||||
|
||||
===== Smarty-3.1.14 =====
|
||||
## Smarty-3.1.14 -
|
||||
27.06.2013
|
||||
- bugfix removed PHP 5.5 deprecated preg_replace /e option in modifier capitalize (forum topic 24389)
|
||||
|
||||
@@ -1269,7 +1337,7 @@
|
||||
24.01.2013
|
||||
- bugfix wrong tag type in smarty_internal_templatecompilerbase.php could cause wrong plugin search order (Forum Topic 24028)
|
||||
|
||||
===== Smarty-3.1.13 =====
|
||||
## Smarty-3.1.13 -
|
||||
13.01.2013
|
||||
- enhancement allow to disable exception message escaping by SmartyException::$escape = false; (Issue #130)
|
||||
|
||||
@@ -1300,7 +1368,7 @@
|
||||
01.11.2012
|
||||
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
||||
|
||||
===== Smarty-3.1.12 =====
|
||||
## Smarty-3.1.12 -
|
||||
14.09.2012
|
||||
- bugfix template inheritance failed to compile with delimiters {/ and /} (Forum Topic 23008)
|
||||
|
||||
@@ -1345,7 +1413,7 @@
|
||||
- bugfix the default plugin handler did create wrong compiled code for static class methods
|
||||
from external script files (issue 108)
|
||||
|
||||
===== Smarty-3.1.11 =====
|
||||
## Smarty-3.1.11 -
|
||||
30.06.2012
|
||||
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||
|
||||
@@ -1358,12 +1426,12 @@
|
||||
11.06.2012
|
||||
- bugfix the patch for Topic 21856 did break tabs between tag attributes (Forum Topic 22124)
|
||||
|
||||
===== Smarty-3.1.10 =====
|
||||
## Smarty-3.1.10 -
|
||||
09.06.2012
|
||||
- bugfix the compiler did ignore registered compiler plugins for closing tags (Forum Topic 22094)
|
||||
- bugfix the patch for Topic 21856 did break multiline tags (Forum Topic 22124)
|
||||
|
||||
===== Smarty-3.1.9 =====
|
||||
## Smarty-3.1.9 -
|
||||
07.06.2012
|
||||
- bugfix fetch() and display() with relative paths (Issue 104)
|
||||
- bugfix treat "0000-00-00" as 0 in modifier.date_format (Issue 103)
|
||||
@@ -1417,7 +1485,7 @@
|
||||
- enhancement the default plugin handler can now also resolve undefined modifier (Smarty::PLUGIN_MODIFIER)
|
||||
(Issue 85)
|
||||
|
||||
===== Smarty-3.1.8 =====
|
||||
## Smarty-3.1.8 -
|
||||
19.02.2012
|
||||
- bugfix {include} could result in a fatal error if used in appended or prepended nested {block} tags
|
||||
(reported by mh and Issue 83)
|
||||
@@ -1464,7 +1532,7 @@
|
||||
- bugfix template inheritance: {$smarty.block.child} in nested child {block} tags did not return
|
||||
content after {$smarty.block.child} (Forum Topic 20564)
|
||||
|
||||
===== Smarty-3.1.7 =====
|
||||
## Smarty-3.1.7 -
|
||||
18.12.2011
|
||||
- bugfix strings ending with " in multiline strings of config files failed to compile (issue #67)
|
||||
- added chaining to Smarty_Internal_Templatebase
|
||||
@@ -1489,7 +1557,7 @@
|
||||
- bugfix template inheritance: {$smarty.block.child} in nested child {block} tags did not return expected
|
||||
result (Forum Topic 20564)
|
||||
|
||||
===== Smarty-3.1.6 =====
|
||||
## Smarty-3.1.6 -
|
||||
30.11.2011
|
||||
- bugfix is_cache() for individual cached subtemplates with $smarty->caching = CACHING_OFF did produce
|
||||
an exception (Forum Topic 20531)
|
||||
@@ -1514,7 +1582,7 @@
|
||||
- bugfix Smarty_Resource::load() did not always return a proper resource handler (Forum Topic 20414)
|
||||
- added escape argument to html_checkboxes and html_radios (Forum Topic 20425)
|
||||
|
||||
===== Smarty-3.1.5 =====
|
||||
## Smarty-3.1.5 -
|
||||
14.11.2011
|
||||
- bugfix allow space between function name and open bracket (forum topic 20375)
|
||||
|
||||
@@ -1546,7 +1614,7 @@
|
||||
- revert PHP4 constructor message
|
||||
- fixed PHP4 constructor message
|
||||
|
||||
===== Smarty-3.1.4 =====
|
||||
## Smarty-3.1.4 -
|
||||
19.10.2011
|
||||
- added exception when using PHP4 style constructor
|
||||
|
||||
@@ -1575,7 +1643,7 @@
|
||||
- bugfix <?xml> tag did create wrong output when caching enabled and the tag was in included subtemplate
|
||||
- bugfix Smarty_CacheResource_mysql example was missing strtotime() calls
|
||||
|
||||
===== Smarty-3.1.3 =====
|
||||
## Smarty-3.1.3 -
|
||||
07.10.2011
|
||||
- improvement removed html comments from {mailto} (Forum Topic 20092)
|
||||
- bugfix testInstall() would not show path to internal plugins_dir (Forum Post 74627)
|
||||
@@ -1602,7 +1670,7 @@
|
||||
- add unloadFilter() method
|
||||
- bugfix has_nocache_code flag was not reset before compilation
|
||||
|
||||
===== Smarty-3.1.2 =====
|
||||
## Smarty-3.1.2 -
|
||||
03.10.2011
|
||||
- improvement add internal $joined_template_dir property instead computing it on the fly several times
|
||||
|
||||
@@ -1642,7 +1710,7 @@
|
||||
extended Smarty class created problems
|
||||
- bugfix error muting was not implemented for cache locking
|
||||
|
||||
===== Smarty 3.1.1 =====
|
||||
## Smarty 3.1.1 -
|
||||
22.09.2011
|
||||
- bugfix {foreachelse} does fail if {section} was nested inside {foreach}
|
||||
- bugfix debug.tpl did not display correctly when it was compiled with escape_html = true
|
||||
@@ -1675,7 +1743,7 @@
|
||||
- bugfix lock_id for file resource would create invalid filepath
|
||||
- bugfix resource caching did not care about file.tpl in different template_dir
|
||||
|
||||
===== Smarty 3.1.0 =====
|
||||
## Smarty 3.1.0 -
|
||||
15/09/2011
|
||||
- optimization of {foreach}; call internal _count() method only when "total" or "last" {foreach} properties are used
|
||||
|
||||
@@ -1768,7 +1836,7 @@
|
||||
- update of README_3_1_DEV.txt and moved into the distribution folder
|
||||
- improvement show first characters of eval and string templates instead sha1 Uid in debug window
|
||||
|
||||
===== Smarty 3.1-RC1 =====
|
||||
## Smarty 3.1-RC1 -
|
||||
25/06/2011
|
||||
- revert change of 17/06/2011. $_smarty varibale removed. call loadPlugin() from inside plugin code if required
|
||||
- code cleanup, remove no longer used properties and methods
|
||||
@@ -1969,7 +2037,7 @@
|
||||
24/12/2010
|
||||
- optimize smarty_function_escape_special_chars() for PHP >= 5.2.3
|
||||
|
||||
===== SVN 3.0 trunk =====
|
||||
## SVN 3.0 trunk -
|
||||
14/05/2011
|
||||
- bugfix error handling at stream resources
|
||||
|
||||
@@ -2029,7 +2097,7 @@
|
||||
- removed obsolete {popup_init..} plugin from demo templates
|
||||
- bugfix replace $smarty->triggerError() by exception in smarty_internal_resource_extends.php
|
||||
|
||||
===== Smarty 3.0.7 =====
|
||||
## Smarty 3.0.7 -
|
||||
09/02/2011
|
||||
- patched vulnerability when using {$smarty.template}
|
||||
|
||||
@@ -2083,7 +2151,7 @@
|
||||
- bugfix {$smarty.template} in child template did not return right content
|
||||
- bugfix Smarty3 did not search the PHP include_path for template files
|
||||
|
||||
===== Smarty 3.0.6 =====
|
||||
## Smarty 3.0.6 -
|
||||
|
||||
12/12/2010
|
||||
- bugfix fixed typo regarding yesterdays change to allow streamWrapper
|
||||
@@ -2118,7 +2186,7 @@
|
||||
- bugfix on template inheritance when an {extends} tag was inserted by a prefilter
|
||||
- added error message for illegal variable file attributes at {extends...} tags
|
||||
|
||||
===== Smarty 3.0.5 =====
|
||||
## Smarty 3.0.5 -
|
||||
|
||||
|
||||
19/11/2010
|
||||
@@ -2145,7 +2213,7 @@
|
||||
- bugfix captured content could not be accessed globally
|
||||
- bugfix Smarty2 wrapper functions could not be call from within plugins
|
||||
|
||||
===== Smarty 3.0.4 =====
|
||||
## Smarty 3.0.4 -
|
||||
|
||||
14/11/2010
|
||||
- bugfix isset() did not allow multiple parameter
|
||||
@@ -2158,7 +2226,7 @@
|
||||
(introduced with 3.0.2)
|
||||
- code cleanup
|
||||
|
||||
===== Smarty 3.0.3 =====
|
||||
## Smarty 3.0.3 -
|
||||
|
||||
13/11/2010
|
||||
- bugfix on {debug}
|
||||
@@ -2167,7 +2235,7 @@
|
||||
- fixed internal_config (removed unwanted code line)
|
||||
- improvement remove last linebreak from {function} definition
|
||||
|
||||
===== Smarty 3.0.2 =====
|
||||
## Smarty 3.0.2 -
|
||||
|
||||
12/11/2010
|
||||
- reactivated $error_reporting property handling
|
||||
@@ -2177,7 +2245,7 @@
|
||||
with transparent access to Smarty object
|
||||
- fixed {config_load} scoping form compile time to run time
|
||||
|
||||
===== Smarty 3.0.0 =====
|
||||
## Smarty 3.0.0 -
|
||||
|
||||
|
||||
|
||||
@@ -2219,7 +2287,7 @@ request_use_auto_globals
|
||||
- bugfix on template inheritance using nested eval or string resource in {extends} tags
|
||||
- bugfix on output buffer handling in isCached() method
|
||||
|
||||
===== RC4 =====
|
||||
## RC4 -
|
||||
|
||||
01/10/2010
|
||||
- added {break} and {continue} tags for flow control of {foreach},{section},{for} and {while} loops
|
||||
@@ -2316,7 +2384,7 @@ request_use_auto_globals
|
||||
15/07/2010
|
||||
- bufix {$smarty.template} does include now the relative path, not just filename
|
||||
|
||||
===== RC3 =====
|
||||
## RC3 -
|
||||
|
||||
|
||||
|
||||
@@ -2370,7 +2438,7 @@ request_use_auto_globals
|
||||
- make handling of Smarty comments followed by newline BC to Smarty2
|
||||
|
||||
|
||||
===== RC2 =====
|
||||
## RC2 -
|
||||
|
||||
|
||||
|
||||
@@ -2442,7 +2510,7 @@ request_use_auto_globals
|
||||
- bugfix on {function} tag with name attribute in doublequoted strings
|
||||
- fix to make calling of template functions unambiguously by madatory usage of the {call} tag
|
||||
|
||||
===== RC1 =====
|
||||
## RC1 -
|
||||
|
||||
27/04/2010
|
||||
- change default of $debugging_ctrl to 'NONE'
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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,69 +1,2 @@
|
||||
# Todo
|
||||
# Pre-release Todos
|
||||
|
||||
## Add unit test for strip issue in correct branch
|
||||
tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php
|
||||
```
|
||||
@@ -76,6 +76,7 @@ class CompileStripTest extends PHPUnit_Smarty
|
||||
array("{'Var'}\n <b></b> <c></c>", 'Var<b></b> <c></c>', '', $i ++),
|
||||
array("\n<b></b> <c></c>", '<b></b> <c></c>', '', $i ++),
|
||||
array("\n<b></b>\n <c></c>", '<b></b><c></c>', '', $i ++),
|
||||
+ array("\n<b>\n {* a comment *}\n <c>", '<b><c>', '', $i ++),
|
||||
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Add unit test for isset issue in correct branch
|
||||
tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php
|
||||
```php
|
||||
/**
|
||||
* test PHP isset() on (non-)variables
|
||||
* @dataProvider dataTestIsset3
|
||||
* @param string $strTemplate template to test
|
||||
* @param string $result expected result
|
||||
*/
|
||||
public function testIsset3($strTemplate, $result)
|
||||
{
|
||||
$this->smarty->disableSecurity();
|
||||
|
||||
$this->smarty->assign('varobject', new TestIsset());
|
||||
$this->smarty->assign('vararray', $vararray = [
|
||||
'keythatexists' => false,
|
||||
'keywitharray' => [1 => 1],
|
||||
'keywithobject' => new TestIsset()]
|
||||
);
|
||||
|
||||
$this->smarty->assign('key', 'A');
|
||||
$this->smarty->assign('_varsimpleA', 1);
|
||||
$this->smarty->assign('varsimpleB', 0);
|
||||
$this->smarty->assign('varsimpleC', null);
|
||||
|
||||
$this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testIsset3
|
||||
*/
|
||||
public function dataTestIsset3()
|
||||
{
|
||||
return array(
|
||||
array('{if isset($varobject->arr)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'),
|
||||
array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varsimpleB)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varsimpleC)}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'),
|
||||
);
|
||||
}
|
||||
```
|
||||
+2
-1
@@ -40,6 +40,7 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "6.4.1"
|
||||
"phpunit/phpunit": "^7.5 || ^6.5 || ^5.7 || ^4.8",
|
||||
"smarty/smarty-lexer": "^3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||
@@ -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']).';?>');
|
||||
|
||||
@@ -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.34-dev-7';
|
||||
const SMARTY_VERSION = '3.1.43';
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
@@ -800,7 +799,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @param mixed $index index of directory to get, null to get all
|
||||
* @param bool $isConfig true for config_dir
|
||||
*
|
||||
* @return array list of template directories, or directory of $index
|
||||
* @return array|string list of template directories, or directory of $index
|
||||
*/
|
||||
public function getTemplateDir($index = null, $isConfig = false)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ])) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -48,6 +48,8 @@ class Smarty_Internal_Method_RegisterPlugin
|
||||
throw new SmartyException("Plugin tag '{$name}' already registered");
|
||||
} elseif (!is_callable($callback)) {
|
||||
throw new SmartyException("Plugin '{$name}' not callable");
|
||||
} elseif ($cacheable && $cache_attr) {
|
||||
throw new SmartyException("Cannot set caching attributes for plugin '{$name}' when it is cacheable.");
|
||||
} else {
|
||||
$smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool)$cacheable, (array)$cache_attr);
|
||||
}
|
||||
|
||||
@@ -85,45 +85,85 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
public function to_smarty_php(Smarty_Internal_Templateparser $parser)
|
||||
{
|
||||
$code = '';
|
||||
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
||||
$subtree = $this->subtrees[ $key ]->to_smarty_php($parser);
|
||||
while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Text ||
|
||||
$this->subtrees[ $key + 1 ]->data === '')) {
|
||||
$key++;
|
||||
if ($this->subtrees[ $key ]->data === '') {
|
||||
continue;
|
||||
}
|
||||
$subtree .= $this->subtrees[ $key ]->to_smarty_php($parser);
|
||||
}
|
||||
if ($subtree === '') {
|
||||
continue;
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$subtree
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
$subtree = $this->subtrees[ $key ]->to_smarty_php($parser);
|
||||
while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Tag ||
|
||||
$this->subtrees[ $key + 1 ]->data === '')) {
|
||||
$key++;
|
||||
if ($this->subtrees[ $key ]->data === '') {
|
||||
continue;
|
||||
}
|
||||
$subtree = $parser->compiler->appendCode($subtree, $this->subtrees[ $key ]->to_smarty_php($parser));
|
||||
}
|
||||
if ($subtree === '') {
|
||||
continue;
|
||||
}
|
||||
$code .= $subtree;
|
||||
continue;
|
||||
}
|
||||
$code .= $this->subtrees[ $key ]->to_smarty_php($parser);
|
||||
|
||||
foreach ($this->getChunkedSubtrees() as $chunk) {
|
||||
$text = '';
|
||||
switch ($chunk['mode']) {
|
||||
case 'textstripped':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$parser->compiler->processText($text)
|
||||
);
|
||||
break;
|
||||
case 'text':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$text
|
||||
);
|
||||
break;
|
||||
case 'tag':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
|
||||
}
|
||||
$code .= $text;
|
||||
break;
|
||||
default:
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= $text;
|
||||
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
private function getChunkedSubtrees() {
|
||||
$chunks = array();
|
||||
$currentMode = null;
|
||||
$currentChunk = array();
|
||||
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
||||
|
||||
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
|
||||
&& $this->subtrees[ $key ]->isToBeStripped()) {
|
||||
$newMode = 'textstripped';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
||||
$newMode = 'text';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
$newMode = 'tag';
|
||||
} else {
|
||||
$newMode = 'other';
|
||||
}
|
||||
|
||||
if ($newMode == $currentMode) {
|
||||
$currentChunk[] = $this->subtrees[ $key ];
|
||||
} else {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
$currentMode = $newMode;
|
||||
$currentChunk = array($this->subtrees[ $key ]);
|
||||
}
|
||||
}
|
||||
if ($currentMode && $currentChunk) {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
}
|
||||
return $chunks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,31 @@
|
||||
*/
|
||||
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
|
||||
{
|
||||
/**
|
||||
* Create template text buffer
|
||||
*
|
||||
* @param string $data text
|
||||
*/
|
||||
public function __construct($data)
|
||||
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @var bool
|
||||
*/
|
||||
private $toBeStripped = false;
|
||||
|
||||
/**
|
||||
* Create template text buffer
|
||||
*
|
||||
* @param string $data text
|
||||
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
|
||||
*/
|
||||
public function __construct($data, $toBeStripped = false)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->toBeStripped = $toBeStripped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @return bool
|
||||
*/
|
||||
public function isToBeStripped() {
|
||||
return $this->toBeStripped;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -680,73 +680,69 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from parser to process a text content section
|
||||
* This method is called from parser to process a text content section if strip is enabled
|
||||
* - remove text from inheritance child templates as they may generate output
|
||||
* - strip text if strip is enabled
|
||||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return null|\Smarty_Internal_ParseTree_Text
|
||||
* @return string
|
||||
*/
|
||||
public function processText($text)
|
||||
{
|
||||
if ((string)$text != '') {
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
if ($this->parser->strip) {
|
||||
if (strpos($text, '<') !== false) {
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all(
|
||||
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$text,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
$expressions = array(// replace multiple spaces between tags by a single space
|
||||
'#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove newline between tags
|
||||
'#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
|
||||
// remove multiple spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
'#>[\040\011]+$#Ss' => '> ',
|
||||
'#>[\040\011]*[\n]\s*$#Ss' => '>',
|
||||
$this->stripRegEx => '',
|
||||
);
|
||||
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
|
||||
$_offset = 0;
|
||||
if (preg_match_all(
|
||||
'#@!@SMARTY:([0-9]+):SMARTY@!@#is',
|
||||
$text,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$text = preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
}
|
||||
return new Smarty_Internal_ParseTree_Text($text);
|
||||
|
||||
if (strpos($text, '<') === false) {
|
||||
return preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
return null;
|
||||
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all(
|
||||
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$text,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
$expressions = array(// replace multiple spaces between tags by a single space
|
||||
'#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove newline between tags
|
||||
'#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
|
||||
// remove multiple spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
'#>[\040\011]+$#Ss' => '> ',
|
||||
'#>[\040\011]*[\n]\s*$#Ss' => '>',
|
||||
$this->stripRegEx => '',
|
||||
);
|
||||
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
|
||||
$_offset = 0;
|
||||
if (preg_match_all(
|
||||
'#@!@SMARTY:([0-9]+):SMARTY@!@#is',
|
||||
$text,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2169,8 +2169,13 @@ class Smarty_Internal_Templateparser
|
||||
// line 255 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
public function yy_r2()
|
||||
{
|
||||
$this->current_buffer->append_subtree($this,
|
||||
$this->compiler->processText($this->yystack[ $this->yyidx + 0 ]->minor));
|
||||
$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));
|
||||
}
|
||||
|
||||
// line 259 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
@@ -2832,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} = " .
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" libs/Smarty.class.php
|
||||
|
||||
git add CHANGELOG.md libs/Smarty.class.php
|
||||
git commit -m "version bump"
|
||||
|
||||
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"
|
||||
|
||||
printf 'Done creating release %s\n' "$1"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
printf 'Run `git push --follow-tags origin` to publish it.\n'
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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}");
|
||||
@@ -95,7 +95,7 @@ class CompileForeachTest extends PHPUnit_Smarty
|
||||
array('{foreach $foo x y foo}{$y}.{$x},{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(9,10,11), '0.9,1.10,2.11,total3', '', $i ++),
|
||||
array('{$x = "hallo"}{$bar=[1,2,3]}{foreach $foo as $x}outer={$x@index}.{$x}#{foreach $bar as $x}inner={$x@index}.{$x}{/foreach}##{/foreach}###{$x}', array(9,10,11), 'outer=0.9#inner=0.1inner=1.2inner=2.3##outer=1.10#inner=0.1inner=1.2inner=2.3##outer=2.11#inner=0.1inner=1.2inner=2.3#####hallo', '', $i ++),
|
||||
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++),
|
||||
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', [], 'else', '', $i ++),
|
||||
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', array(), 'else', '', $i ++),
|
||||
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', new \ArrayIterator(), 'else', '', $i ++),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ class CompileInsertTest extends PHPUnit_Smarty
|
||||
* test insert plugin caching 2
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @group slow
|
||||
*/
|
||||
public function testInsertPluginCaching3_2()
|
||||
{
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -76,7 +76,7 @@ class CompileStripTest extends PHPUnit_Smarty
|
||||
array("{'Var'}\n <b></b> <c></c>", 'Var<b></b> <c></c>', '', $i ++),
|
||||
array("\n<b></b> <c></c>", '<b></b> <c></c>', '', $i ++),
|
||||
array("\n<b></b>\n <c></c>", '<b></b><c></c>', '', $i ++),
|
||||
|
||||
array("\n<b>\n {* a comment *}\n <c>", '<b><c>', '', $i ++),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
public function testEmpty2()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP > 5.5');
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
|
||||
$this->smarty->disableSecurity();
|
||||
@@ -82,7 +82,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
public function testEmpty3()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP > 5.5');
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
$this->smarty->disableSecurity();
|
||||
$this->smarty->assign('var', array(true,
|
||||
@@ -104,7 +104,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
public function testEmpty4()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP > 5.5');
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
|
||||
$this->smarty->disableSecurity();
|
||||
@@ -156,6 +156,57 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
,{if isset($var->pass(1))} true {else} false {/IF}
|
||||
'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test PHP isset() on (non-)variables
|
||||
* @dataProvider dataTestIsset3
|
||||
* @param string $strTemplate template to test
|
||||
* @param string $result expected result
|
||||
*/
|
||||
public function testIsset3($strTemplate, $result)
|
||||
{
|
||||
$this->smarty->disableSecurity();
|
||||
|
||||
$this->smarty->assign('varobject', new TestIsset());
|
||||
$this->smarty->assign('vararray', $vararray = array(
|
||||
'keythatexists' => false,
|
||||
'keywitharray' => array(1 => 1),
|
||||
'keywithobject' => new TestIsset()
|
||||
));
|
||||
|
||||
$this->smarty->assign('key', 'A');
|
||||
$this->smarty->assign('_varsimpleA', 1);
|
||||
$this->smarty->assign('varsimpleB', 0);
|
||||
$this->smarty->assign('varsimpleC', null);
|
||||
|
||||
$this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testIsset3
|
||||
*/
|
||||
public function dataTestIsset3()
|
||||
{
|
||||
return array(
|
||||
array('{if isset($varobject->arr)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'),
|
||||
array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varsimpleB)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($varsimpleC)}true{else}false{/if}', 'false'),
|
||||
array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'),
|
||||
array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,4 +234,4 @@ class TestIsset {
|
||||
public function pass($v) {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user