Compare commits

..

289 Commits

Author SHA1 Message Date
Simon Wisselink a3b5e4eaf9 fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable 2020-04-13 00:47:34 +02:00
Simon Wisselink cf8b820f2c synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config 2020-04-13 00:38:03 +02:00
Simon Wisselink 5db1746129 Removed unneeded files and replace dummy.txt with .gitignore files 2020-04-13 00:03:57 +02:00
Simon Wisselink 57d797fa1d Merge branch 'master' of smarty-php/smarty-phpunit into feature/merge_smarty-phpunit_into_tests_subfolder 2020-04-12 23:15:47 +02:00
Simon Wisselink 2142913e3b Add additional unit tests for several isset issues 2020-01-28 11:42:40 +01:00
Simon Wisselink e1ebc2ac8e Added test for foreachelse on arrayiterators and such https://github.com/smarty-php/smarty/issues/506 2020-01-27 16:01:22 +01:00
uwetews cd4fd962dc Merge pull request #3 from smarty-php/revert-1-fix-composer-deps
Revert "Reinstitute the phpunit/phpunit dependency the right way."
2018-12-09 04:53:14 +01:00
uwetews 7ff8bdb173 Revert "Reinstitute the phpunit/phpunit dependency the right way." 2018-12-09 04:51:05 +01:00
uwetews 9ec3d2d67b Merge pull request #1 from AnrDaemon/fix-composer-deps
Reinstitute the phpunit/phpunit dependency the right way.
2018-12-09 02:35:07 +01:00
AnrDaemon 317f05e348 Reinstitute the phpunit/phpunit dependency the right way. 2018-12-06 20:15:37 +03:00
uwetews 06c4eac7c0 fix {insert} test 2018-11-11 18:35:00 +01:00
uwetews adbcf8a014 Update insert tag tests https://github.com/smarty-php/smarty/issues/496 2018-10-09 06:27:32 +02:00
uwetews 578503c474 Update modifier test https://github.com/smarty-php/smarty/issues/491 2018-10-09 03:28:42 +02:00
uwetews e250f28db7 added test - bugfix some custom left and right delimiters like '{^' '^}' did not work
https://github.com/smarty-php/smarty/issues/450 https://github.com/smarty-php/smarty/pull/482
2018-08-31 17:29:59 +02:00
Uwe Tews 5359963c27 Disable test for now 2018-05-17 04:56:43 +02:00
Uwe Tews 05ce67754a added security test case 2018-04-26 21:37:38 +02:00
Uwe Tews 18d15d7669 add enableSecurity() 2018-04-26 18:00:17 +02:00
Uwe Tews 2f87c74cba update securitytests 2018-04-26 13:33:21 +02:00
Uwe Tews d59e6804fc Update for {fetch} plugin 2018-04-26 12:59:14 +02:00
Uwe Tews c4f3d4fb98 Update for {fetch} plugin 2018-04-25 15:40:25 +02:00
Uwe Tews ced3bf86d8 Update template function tests 2018-03-28 07:02:18 +02:00
Uwe Tews 8f8030805a fix @runInSeparateProcess 2018-03-28 00:55:14 +02:00
Uwe Tews 12b7512311 update new plugin handling 2018-03-27 02:03:37 +02:00
Uwe Tews a341b00676 new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child} 2018-03-26 22:26:49 +02:00
Uwe Tews 5fb73cd3c1 short form of {section} attributes did not work https://github.com/smarty-php/smarty/issues/428 2018-03-21 15:17:56 +01:00
Uwe Tews dfdf343b2d https://github.com/smarty-php/smarty/issues/422 2018-03-21 07:35:25 +01:00
Uwe Tews a364e82c6b Test for issue 419 2018-03-16 18:28:49 +01:00
Uwe Tews cbf7e15e2a Update readme.md 2017-11-22 05:21:44 +01:00
Uwe Tews 1a11b61b73 Extend setfilter tag test 2017-11-20 11:26:25 +01:00
Uwe Tews 9d52ba99f7 Extend setfilter tag test 2017-11-20 11:10:45 +01:00
Uwe Tews 1e48db70cf Disable mysql tests 2017-11-20 04:14:57 +01:00
Uwe Tews afd68d7104 Update 2017-11-20 02:17:35 +01:00
Uwe Tews b3a64efa14 Update mysql tests 2017-11-20 00:55:43 +01:00
Uwe Tews ccefb46c30 Update msql resource test 2017-11-19 19:52:31 +01:00
Uwe Tews 0d8ddddc1b Update spacing tests 2017-11-19 10:50:49 +01:00
Uwe Tews bea59cdec4 add and rework tests
add spacing tests for newlines between tags and text
3.1.32-dev-36
2017-11-17 10:41:04 +01:00
Uwe Tews eabde8aaef remove redundant test 2017-11-11 16:19:10 +01:00
Uwe Tews ab726e92df add spacing tests 2017-11-11 14:52:51 +01:00
Uwe Tews ae900c9ebe Disable tests which do not run on PHP 5.4 and below 2017-11-06 04:32:19 +01:00
Uwe Tews 8a6f2493c6 Update exception messages 3.1.32-dev-33 2017-11-05 20:40:46 +01:00
Uwe Tews 51c813556c modified tests for custom delimiters 2017-10-21 12:35:08 +02:00
Uwe Tews 507b96a571 remove E_DEPRECATED for PHP 5.2 compatibility
restore @runTestsInSeparateProcess
2017-10-18 12:59:55 +02:00
Uwe Tews 37288b44e0 update tests to cover
https://github.com/smarty-php/smarty/issues/396 https://github.com/smarty-php/smarty/issues/397
    https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392
2017-10-18 09:12:59 +02:00
Uwe Tews fd1846a286 Update double qouted string test 2017-10-12 20:03:28 +02:00
Uwe Tews f41afe355f Update block extends tests https://github.com/smarty-php/smarty/issues/393 2017-10-12 08:11:30 +02:00
Uwe Tews df97b8a14d do not ignore vendor folder because of travis tests 2017-10-09 19:11:35 +02:00
Uwe Tews 3c7f0826d3 Update error_reporting setting 2017-10-09 10:21:16 +02:00
Uwe Tews 462efddfdf Update for 3.1.32-dev-23 2017-10-07 08:22:00 +02:00
Uwe Tews e3e8088029 Add test for boolean and null 2017-09-03 04:49:33 +02:00
Uwe Tews a202d5b464 add test for issue 327 2017-08-26 11:46:33 +02:00
Uwe Tews 661ffe75ef update for 3.1.32-dev 2017-08-09 12:50:32 +02:00
Uwe Tews 2302db0b78 revert last change 2017-07-30 05:07:27 +02:00
Uwe Tews 3c0cc4da1c Update because of https://github.com/smarty-php/smarty/pull/377 2017-07-21 07:00:28 +02:00
uwetews 5c4871a842 Update tests 2017-05-27 12:33:02 +02:00
uwetews 3db8beb54a Update tests 2017-05-27 12:17:09 +02:00
uwetews 889fd2debf Update tests 2017-05-27 11:27:50 +02:00
uwetews 52f84dc39d PHP 5.2 compatibility 2017-05-21 19:14:39 +02:00
uwetews ae311ee2e8 disable closure for PHP 5.2 2017-05-21 18:57:16 +02:00
uwetews 6fcb23196a disable closure for PHP 5.2 2017-05-21 18:54:13 +02:00
uwetews 03900cec3a disable closure for PHP 5.2 2017-05-21 18:41:44 +02:00
uwetews 4f41768ef7 disable closure for PHP 5.2 2017-05-21 18:32:19 +02:00
uwetews 99b782b257 add PHP function tests 2017-04-17 04:20:34 +02:00
uwetews 5fe8455e87 remove coverage from phpunit.xml 2017-04-14 13:08:10 +02:00
uwetews c3afe0bc9d Update for PHPunit >= 5 2017-04-14 12:16:33 +02:00
uwetews 2652c5ef26 reomove require for phpunit 2017-04-14 05:37:17 +02:00
uwetews 62cc0c0e2a Update for PHPunit >= 5 2017-04-14 02:25:56 +02:00
uwetews 279240f76d Delete composer.lock 2017-04-13 19:42:55 +02:00
uwetews 31a515470d Update for PHPunit 5.7 2017-04-13 19:32:44 +02:00
uwetews 7645ae0512 remove version check code 2016-11-19 18:02:13 +01:00
uwetews 5f92ee4ea0 delete wrong test 2016-11-19 07:50:24 +01:00
uwetews eea6256875 gh312 bug test 2016-11-12 09:31:48 +01:00
uwetews f026729c5c gh312 bug test 2016-11-12 09:31:20 +01:00
uwetews 43eb0f3986 update 2016-11-12 01:32:26 +01:00
uwetews b7f845f5a9 test will run sinc php 5.6 2016-11-11 23:03:46 +01:00
uwetews 9bfc85b045 test requires php 5.5 2016-11-11 21:54:08 +01:00
uwetews c0110c1051 add tests for issuse 312 2016-11-11 20:10:23 +01:00
uwetews 6c5e729c9c add test for config variable overloading 2016-10-27 05:28:23 +02:00
uwetews 8e42150426 Test template function call in fetched template 2016-10-27 05:24:08 +02:00
uwetews bfb502b633 {make_nocache} add space test 2016-10-19 20:40:41 +02:00
uwetews 411390b579 update {make_nocache} tests 2016-10-19 19:35:05 +02:00
uwetews 48a954e2e5 Add test for Smarty::$extends_recursion property 2016-09-29 03:44:49 +02:00
uwetews e1ad0ece66 Test <?xml ?> tags in subtemplate 2016-09-28 23:32:01 +02:00
uwetews 81852c085f Test isset() 0n $smarty.foreache special variables 2016-09-20 14:17:17 +02:00
uwetews 75432afb05 Update clear compiled tests 2016-09-20 10:18:08 +02:00
uwetews eebbecf603 Update clear compiled tests 2016-09-19 22:25:57 +02:00
uwetews da69e4d7af Updates because new release update checks 2016-09-19 08:02:34 +02:00
uwetews 268368f2a4 Updates because new release update checks 2016-09-19 07:36:20 +02:00
uwetews 30f7c15d01 update string resource test 2016-09-15 09:25:11 +02:00
uwetews 998b28dcc8 update resource tests 2016-09-15 09:09:00 +02:00
uwetews 0d5dab3b66 Extended {foreach} tests 2016-09-09 22:41:25 +02:00
uwetews 2e9ee3b2a0 add test for getConfigVariable() 2016-09-08 22:19:07 +02:00
uwetews be86d1eb6d replace constant DS with DIRECTORY_SEPARATOR 2016-08-23 07:56:09 +02:00
uwetews 490fb5eaa5 upate unit test 2016-08-14 11:24:22 +02:00
uwetews 1d76572e9a update scope with test for {assign.. noscope} 2016-08-14 03:11:10 +02:00
uwetews e3f5e325ab disable mysql because msql setup problems under HHVM 2016-08-07 20:09:46 +02:00
uwetews 0aab6c9ff6 enable mysql 2016-08-07 19:35:17 +02:00
uwetews fd8f010b05 update config tests 2016-08-07 12:57:48 +02:00
uwetews f8420363b8 Update default handler teste 2016-08-05 21:22:23 +02:00
uwetews 3155e9ce8e Update compiler error 2016-07-25 20:36:36 +02:00
uwetews 419bfe2bc2 update resource tests 2016-07-25 20:32:58 +02:00
uwetews 4354315bb2 add plugins_dir and template_dir normalization test 2016-07-25 20:27:26 +02:00
uwetews e494f65a77 Extend default handler 2016-07-12 23:37:51 +02:00
uwetews bfca72e71b update compiler plugin test 2016-07-12 23:01:29 +02:00
uwetews 93bc56e14f Update security test 2016-07-12 02:28:56 +02:00
uwetews 688151e06f Update capture test 2016-07-12 00:25:14 +02:00
uwetews b823237d67 update unit teste 2016-05-15 11:12:04 +02:00
uwetews 8a8c0cd081 Update inheritance tests 2016-05-01 23:49:04 +02:00
uwetews ec1caa0905 Update strip tests 2016-04-29 00:14:59 +02:00
uwetews 6245f65402 Update capture test 2016-04-14 21:06:51 +02:00
uwetews 66f6c54281 Update {extends} test 2016-04-13 03:30:32 +02:00
uwetews b08b8f1d3a Update capture test 2016-03-27 18:34:13 +02:00
uwetews f6a0749845 revert 2016-03-11 05:57:58 +01:00
uwetews 9802c9291d disable msql 2016-03-11 05:54:32 +01:00
uwetews c6a60a82ca enable memcache amd msql 2016-03-11 05:49:03 +01:00
uwetews 9a291b8da4 add clearCompiledTemplate() tests 2016-03-11 03:29:57 +01:00
uwetews d744c408fe update php resource tests 2016-03-10 20:56:33 +01:00
uwetews 531df47a97 Update scope tests 2016-03-09 00:29:15 +01:00
uwetews d717439a6b Update path normalization test 2016-02-25 23:30:32 +01:00
uwetews 788aa58632 Update strip text 2016-02-20 17:17:21 +01:00
uwetews 13c7a912d9 clear static tag compiler object cache 2016-02-15 14:19:01 +01:00
uwetews 3dcb718b5d update attribute test 2016-02-14 19:46:11 +01:00
uwetews a073234fe3 Add test for new {make_nocache} tag 2016-02-14 03:04:50 +01:00
uwetews 0bcf2127d1 Add test for new {make_nocache} tag 2016-02-14 02:49:22 +01:00
uwetews 2dba744fcb Update function plugin teste 2016-02-10 21:06:19 +01:00
uwetews 90a4a5c28e add more tests for strip 2016-02-10 21:05:36 +01:00
uwetews db8553be32 update test 2016-02-10 03:16:12 +01:00
uwetews 150d24822d update strip test 2016-02-10 01:08:01 +01:00
uwetews 2f7c0f0a99 update if test 2016-02-09 04:18:30 +01:00
uwetews ac5070ea87 update scope tests 2016-02-09 01:40:34 +01:00
uwetews e0d4e4b1fa new core functions 2016-02-09 01:32:50 +01:00
uwetews c48e16c5fe add {break} test 2016-02-01 20:23:25 +01:00
uwetews 33bdb44723 add {break} and {continue} tests 2016-01-29 02:33:40 +01:00
uwetews 39631cce4b add test for block plugin tag stack 2016-01-29 01:08:54 +01:00
uwetews dcb0d4be63 add {extends} tests with relative path 2016-01-27 04:44:05 +01:00
uwetews dd935863bd add output filter tests for caching and nocache code 2016-01-27 00:28:36 +01:00
uwetews 2b7615e23d add nocache teste 2016-01-03 08:18:52 +01:00
uwetews 7bfe828d70 add block plugin caching test 2016-01-02 21:27:37 +01:00
uwetews 7611bedfb5 dummy 2016-01-02 16:59:37 +01:00
uwetews 9307076ffa update block plugin tests 2016-01-02 16:59:02 +01:00
uwetews 42b864b707 update block plugin tests 2016-01-02 11:48:31 +01:00
uwetews 5f7417d495 update block plugin tests 2016-01-02 11:39:16 +01:00
uwetews a56e36c811 update block plugin tests 2016-01-02 11:33:29 +01:00
uwetews a194dd0950 update block plugin tests 2016-01-02 11:17:12 +01:00
uwetews 585850230c update block plugin tests 2016-01-02 04:56:22 +01:00
uwetews fb7908d710 add missing plugin 2016-01-02 02:53:18 +01:00
uwetews c26d0ed365 update scope tests for {config_load} 2016-01-02 02:37:14 +01:00
uwetews 978d7c88c5 update scope tests for {include} 2016-01-02 02:12:31 +01:00
uwetews bac6e3c069 remove old scope tests 2016-01-02 01:33:52 +01:00
uwetews 7caf793eeb add scope tests for {assign} 2016-01-02 00:48:20 +01:00
uwetews eee2bc3a77 add prefilter 2016-01-02 00:43:44 +01:00
uwetews cc68ce89ec disable memcache 2016-01-01 18:51:57 +01:00
uwetews 3b5ff51e0e test if class exists 2015-12-31 06:32:20 +01:00
uwetews ffe0095b80 enable memcache test 2015-12-31 06:30:16 +01:00
uwetews 622bea89f9 PHP 5.2 compatibility 2015-12-31 06:03:21 +01:00
uwetews e363a78e28 replace __DIR__ 2015-12-31 05:38:36 +01:00
uwetews 83e7c90c20 replace __DIR__ 2015-12-31 05:36:00 +01:00
uwetews 66fa8ce092 remove closure test 2015-12-31 05:26:58 +01:00
uwetews 9a61f1511c skip closure on php 5.2 2015-12-31 05:20:00 +01:00
uwetews 1981dd8016 replace __DIR__ 2015-12-31 05:04:07 +01:00
uwetews db914a947d disable mysql for travis because problems under hhvm 2015-12-31 04:06:44 +01:00
uwetews 06b37842dd disable memcached for travis 2015-12-31 03:48:06 +01:00
uwetews 039f1f72f6 enable memcached for travis 2015-12-31 03:43:55 +01:00
uwetews 9b87168a14 disable memcached for travis 2015-12-31 03:34:32 +01:00
uwetews 5c6b9dd186 set time zone 2015-12-31 03:30:14 +01:00
uwetews bf93a7b356 Update 2015-12-31 03:20:56 +01:00
uwetews 3086b4e53d Fix msql test 2015-12-31 03:02:34 +01:00
uwetews ac996820cc enable mysql and memcached tests for travis 2015-12-31 02:48:20 +01:00
uwetews 97b02e9a2e Update {assign] tests 2015-12-31 02:06:18 +01:00
uwetews e390da71e2 https://github.com/smarty-php/smarty/issues/147 2015-12-30 22:27:16 +01:00
uwetews d0f29ae730 add {$smarty.template} and {$smarty.current_dir} tests 2015-12-30 21:24:31 +01:00
uwetews b887f18acf update configuration of disabled resource tests 2015-12-30 21:14:22 +01:00
uwetews 1800432c4c Test E_NOTICE suppression on undefined variables https://github.com/smarty-php/smarty/issues/145 2015-12-30 18:23:46 +01:00
uwetews 7ce2a7dd41 Add SmartyBC tests 2015-12-30 17:45:11 +01:00
uwetews 43237f1526 Add SmartyBC tests 2015-12-30 01:08:02 +01:00
uwetews 25108d3636 Add SmartyBC tests 2015-12-30 00:54:20 +01:00
uwetews e506550ef2 Add SmartyBC tests 2015-12-30 00:46:09 +01:00
uwetews d72ced4e70 Smarty2 wrapper tests 2015-12-30 00:28:27 +01:00
uwetews 9ffad00177 Smarty2 wrapper tests 2015-12-29 21:14:32 +01:00
uwetews 3229f0563b Smarty2 wrapper tests 2015-12-29 20:51:56 +01:00
uwetews 1d1c9bc59e Smarty2 wrapper tests 2015-12-29 19:24:15 +01:00
uwetews 381556a290 Update {foreach} tests 2015-12-28 00:51:28 +01:00
uwetews a4e6d6d609 Update {block} {extends} test 2015-12-27 05:05:54 +01:00
uwetews 3c4361c1c4 Update test 2015-12-25 09:58:40 +01:00
uwetews 3d4fbb88c6 Update extends test 2015-12-25 08:48:25 +01:00
uwetews 6b9648a1dc add post filter test https://github.com/smarty-php/smarty/issues/144 2015-12-24 06:27:11 +01:00
uwetews b4613146b4 Update 2015-12-24 01:56:38 +01:00
uwetews 09d29deeea Add tests for changed template_dir settings 2015-12-24 01:54:50 +01:00
uwetews 007de1fefa Update for file uid changes of 3.1.30 2015-12-24 01:52:30 +01:00
uwetews 1723095862 caching observes now template_dir setting 2015-12-23 04:27:56 +01:00
uwetews 954ea7d963 add test for direct access of protected xxx_dir properties 2015-12-22 01:14:00 +01:00
uwetews 5f9e853035 update strip test 2015-12-21 23:33:41 +01:00
uwetews 5af36fa255 add filepath normalization tests 2015-12-21 22:45:49 +01:00
uwetews cd1d7c4d6a add test where extendsall is default resource 2015-12-21 02:13:46 +01:00
uwetews b1bd7dd347 extend runtime parameter because timing problem on travis 2015-12-20 15:36:57 +01:00
uwetews 781a355436 fix test class name 2015-12-20 14:52:23 +01:00
uwetews 77149f22f6 add Smarty special variable teste 2015-12-20 14:45:25 +01:00
uwetews b4cf3c3d5c insert dummy.txt 2015-12-20 11:25:37 +01:00
uwetews 669bf0ddcd delet dummy.txt (reverted from commit 8c9fe47fa36702daf3c7acb255b442c7c04f685b) (reverted from commit f66230d6df15615e9b33b54f2a97ca7c46be474d) 2015-12-20 11:02:44 +01:00
uwetews 90564a8fb0 delet dummy.txt (reverted from commit 8c9fe47fa36702daf3c7acb255b442c7c04f685b) 2015-12-20 11:00:35 +01:00
uwetews cd5cc546a9 delet dummy.txt 2015-12-20 10:55:45 +01:00
uwetews e9e473da65 add test for chained prepend 2015-12-18 03:58:53 +01:00
uwetews 3d7a1d57dc update strip test 2015-12-09 01:31:15 +01:00
uwetews cee9d19fba Update test for 3.1.28 master 2015-10-24 04:12:28 +02:00
uwetews e4ed69f174 fix test 2015-10-20 01:28:39 +02:00
uwetews 4c24ec6e20 split tests because of hhvm 2015-10-20 01:21:37 +02:00
uwetews 03daa2880c run all test in separate process 2015-10-20 00:50:22 +02:00
uwetews 3975172178 config change 2015-10-18 20:53:31 +02:00
uwetews d44e283eb7 add dummy 2015-10-18 20:43:38 +02:00
uwetews dde9a906b0 add dummies 2015-10-18 20:33:53 +02:00
uwetews 749eaad939 run some tests in separate process for HHVM compatibillity 2015-10-18 20:23:49 +02:00
uwetews 75663948f2 move configuration constants in PHP file that they are seen also in isolated tests 2015-10-18 20:22:11 +02:00
uwetews 48676467ce no log file 2015-10-18 07:21:06 +02:00
uwetews 48b7147869 some test must run in separate process under because of HHVM 2015-10-18 05:41:46 +02:00
uwetews 538ffd3af2 Update forr 3.1.28 2015-10-18 03:33:17 +02:00
uwetews 60f73dfcb7 Extend tests 2015-09-01 02:47:13 +02:00
uwetews d5c9859241 Update tests 2015-08-29 14:23:14 +02:00
uwetews 4645b78e8b add dummy files to keep folder in reprository 2015-08-23 18:32:10 +02:00
uwetews 5c416f2f0f Update for 3.1.28 2015-08-23 15:04:21 +02:00
Uwe Tews 75adb86450 fix timestamp 2015-08-06 21:11:41 +02:00
Uwe Tews 1a5654040f fix exception results 2015-08-02 21:02:56 +02:00
Uwe Tews 621d99643c remove check of uid from exception result 2015-08-01 14:10:37 +02:00
Uwe Tews b829b94df8 Update 2015-07-30 02:02:53 +02:00
Uwe Tews a6f6f6fd6d update 2015-07-30 01:50:45 +02:00
Uwe Tews 5f0c8fd58a disable test7 2015-07-30 00:00:56 +02:00
Uwe Tews cf2b0c8aed Update section tests 2015-07-29 23:28:57 +02:00
Uwe Tews 63b3f4c522 remove PHP_ALLOW test for <script language='php'> for PHP 7 as it is not supported 2015-07-28 01:47:08 +02:00
Uwe Tews b4dc05df12 remove PHP_ALLOW test for <script language='php'> for PHP 7 as it is not supported 2015-07-28 01:35:24 +02:00
Uwe Tews 84dbaa901b Fix tests for HHVM 2015-07-28 00:50:27 +02:00
Uwe Tews b1ffb59c3c Update 2015-07-07 18:35:49 +02:00
Uwe Tews 62d0c170a0 Update file resource tests 2015-07-07 17:11:05 +02:00
Uwe Tews a0f18578e2 Update file resource tests 2015-07-07 00:49:20 +02:00
Uwe Tews cb70b219ad update $source->getContent() 2015-07-01 16:57:50 +02:00
Uwe Tews 5f8f92d75b Update 2015-07-01 03:13:32 +02:00
Uwe Tews 441ac8e100 Add closure test 2015-06-19 03:00:20 +02:00
Uwe Tews 9400c6307f Delete 2015-06-18 03:26:46 +02:00
Uwe Tews 77abff1e53 normalize path 2015-06-18 03:07:19 +02:00
Uwe Tews cbeede4f8c update 2015-06-18 02:04:13 +02:00
Uwe Tews c34c178053 check plugin loading 2015-06-18 01:45:13 +02:00
Uwe Tews e5b3da5b38 Update path normalization 2015-06-18 00:17:57 +02:00
Uwe Tews c1d6ae68f4 Test simplw plugin nocache 2015-06-17 20:59:56 +02:00
Uwe Tews 609ae0d708 Update for 3.1.25 2015-06-14 02:56:18 +02:00
Uwe Tews 1500b2e655 update for <?xml tags including template variables 2015-06-01 22:14:41 +02:00
Uwe Tews b55f4cf551 New PHP tests 2015-05-23 18:53:25 +02:00
Uwe Tews 66f127cab1 New PHP tests 2015-05-23 18:49:46 +02:00
Uwe Tews cb31ef2df1 New PHP tests 2015-05-23 18:49:27 +02:00
Uwe Tews e3c82a8f06 Test long comment 2015-05-23 18:48:27 +02:00
Uwe Tews 15abaf4842 Test long comment 2015-05-23 18:48:04 +02:00
Uwe Tews 5bb2c5c26f Update bootstrap 2015-05-21 00:53:04 +02:00
Uwe Tews 47b6fab3d9 fix result 2015-05-20 05:05:28 +02:00
Uwe Tews 2614b1aacb fix true 2015-05-18 08:11:50 +02:00
Uwe Tews 37d327ce12 Update 2015-05-18 05:36:37 +02:00
Uwe Tews 9cd0734f70 Modified Php tag tests to multiple php lines. 2015-05-16 14:57:14 +02:00
Uwe Tews f6b369263e Modified Php tag tests to multiple php lines. 2015-05-16 14:48:38 +02:00
Uwe Tews e1a34fbc87 added recursive template function tests 2015-05-14 15:03:55 +02:00
Uwe Tews 59de25809e added recursive template function tests 2015-05-14 15:02:52 +02:00
Uwe Tews 5bef25a262 Added unit test for issue 28 and 29 2015-05-12 20:44:52 +02:00
Uwe Tews 4a09745c41 Update for Linux results 2015-05-12 03:50:24 +02:00
Uwe Tews eed5b1ddf3 add lockfile for phpunit 2015-05-12 02:36:43 +02:00
Uwe Tews 78e0072c15 Delete 2015-05-10 23:05:55 +02:00
Uwe Tews a451662760 update 2015-05-10 22:59:33 +02:00
Uwe Tews 8d75f927aa add travis.yml 2015-05-10 22:57:17 +02:00
Uwe Tews 79f1d70d97 added tests for cache locking 2015-05-10 12:52:00 +02:00
Uwe Tews 41c4c598af add tests for cache locking 2015-05-06 22:54:41 +02:00
Uwe Tews ce756af4ca Update tests 2015-05-05 23:45:28 +02:00
Uwe Tews bca7eaeba5 test 2015-05-05 04:18:56 +02:00
Uwe Tews a97f68068d test 2015-05-05 04:15:20 +02:00
Uwe Tews 6fa1f3c6a4 test 2015-05-05 04:13:18 +02:00
Uwe Tews 0a1d2c20c7 test 2015-05-05 04:11:44 +02:00
Uwe Tews e9b9ba2d40 test 2015-05-05 04:03:41 +02:00
Uwe Tews 619c1d2830 try to catch excluded files right 2015-05-05 01:06:43 +02:00
Uwe Tews ef317b50ae try to catch excluded files right 2015-05-05 01:05:27 +02:00
Uwe Tews 81aae13e55 Smarty 3.1.22 code change
- improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24)
2015-05-05 01:03:12 +02:00
Uwe Tews 8056c27602 3.1.21 2015-05-04 04:08:56 +02:00
Uwe Tews cf11a8a4b9 3.1.20 2015-05-04 04:06:29 +02:00
Uwe Tews 69b2f86d91 3.1.20 2015-05-04 04:03:09 +02:00
Uwe Tews 26146a67a6 3.1.19 2015-05-04 04:01:13 +02:00
Uwe Tews 0566d8a657 3.1.18 2015-05-04 03:58:51 +02:00
Uwe Tews 94545f2d4e 3.1.17 2015-05-04 03:56:51 +02:00
Uwe Tews 4cc66c650a 3.1.16 2015-05-04 03:54:54 +02:00
Uwe Tews 819b852809 3.1.15 2015-05-04 03:52:20 +02:00
Uwe Tews d3e78d81bc 3.1.14 2015-05-04 03:12:52 +02:00
Uwe Tews 7ad54c9887 3.1.13 2015-05-04 03:10:52 +02:00
Uwe Tews fe8598515f 3.1.12 2015-05-04 03:07:10 +02:00
Uwe Tews 0dea9f271c 3.1.11 2015-05-04 03:00:52 +02:00
Uwe Tews 1834622d94 Revert "3.1.11"
This reverts commit d3af847798ed757770a5a0d336fa04780a7ec2cd.
2015-05-04 02:23:23 +02:00
Uwe Tews 429229d6b6 3.1.11 2015-05-04 02:22:20 +02:00
Uwe Tews 5feb5b44dd Update 2015-05-04 02:21:34 +02:00
Uwe Tews 27addcf628 init 2015-05-04 02:17:48 +02:00
uwetews 6eedb590e1 Initial commit 2015-05-04 02:14:20 +02:00
284 changed files with 6922 additions and 4093 deletions
+7 -8
View File
@@ -6,12 +6,11 @@
*.lex text eol=lf
# exclude from git export
/tests export-ignore
/utilities/ export-ignore
/.gitattributes export-ignore
/travis.ini export-ignore
/myconfig.ini export-ignore
/.travis.yml export-ignore
/.gitignore export-ignore
/make-release.sh export-ignore
/phpunit.sh export-ignore
/phpunit.xml export-ignore
/TODO.md export-ignore
/.gitattributes export-ignore
/lexer/ export-ignore
/utilities/ export-ignore
/error_reporting.ini export-ignore
-73
View File
@@ -1,73 +0,0 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
on:
- pull_request
- push
name: CI
jobs:
tests:
name: Tests
runs-on: ${{ matrix.os }}
env:
PHP_EXTENSIONS: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
PHP_INI_VALUES: assert.exception=1, zend.assertions=1
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
compiler:
- default
include:
- os: ubuntu-latest
php-version: "8.0"
compiler: jit
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Override PHP ini values for JIT compiler
if: matrix.compiler == 'jit'
run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=32M" >> $GITHUB_ENV
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run tests with phpunit
run: ./phpunit.sh
-1
View File
@@ -9,6 +9,5 @@ utilies/*.php
# Dev
phpunit*
.phpunit.result.cache
vendor/*
composer.lock
+34
View File
@@ -0,0 +1,34 @@
language: php
sudo: false
dist: trusty
matrix:
include:
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly
fast_finish: true
allow_failures:
- php: nightly
services:
- memcached
- mysql
before_script:
- mysql -e "create database IF NOT EXISTS test;" -uroot
before_install:
- phpenv config-rm xdebug.ini || return 0
install:
- travis_retry composer install
script:
- ./phpunit.sh
+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 3.0 of the License, or (at your option) any later version.
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
+1 -1
View File
@@ -51,7 +51,7 @@ $smarty->unregisterFilter(...)
Please refer to the online documentation for all specific changes:
https://www.smarty.net/documentation
http://www.smarty.net/documentation
----
+6 -3
View File
@@ -1,7 +1,7 @@
# Smarty 3 template engine
[smarty.net](https://www.smarty.net/)
![CI](https://github.com/smarty-php/smarty/workflows/CI/badge.svg)
[![Build Status](https://travis-ci.org/smarty-php/smarty.svg?branch=master)](https://travis-ci.org/smarty-php/smarty)
## Documentation
@@ -9,7 +9,8 @@ For documentation see
[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/)
## Requirements
Smarty can be run with PHP 7.1 to PHP 8.0.
Smarty can be run with PHP 5.2 to PHP 7.4.
## Distribution repository
@@ -17,7 +18,7 @@ Smarty can be run with PHP 7.1 to PHP 8.0.
> 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.
@@ -73,3 +74,5 @@ Or you could use:
```
Which is a wrapper to install all 3 packages.
Composer can also be used for Smarty2 versions 2.6.24 to 2.6.30.
-19
View File
@@ -1,19 +0,0 @@
# Security Policy
## Supported Versions
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.)
| Version | Supported |
| ------- | ------------------ |
| 4.0.x | :white_check_mark: |
| 3.1.x | :white_check_mark: |
| < 3.1 | :x: |
## Reporting a Vulnerability
If you have discovered a security issue with Smarty, please contact us at mail [at] simonwisselink.nl. Do not
disclose your findings publicly and PLEASE PLEASE do not file an Issue.
We will try to confirm the vulnerability and develop a fix if appropriate. When we release the fix, we will publish
a security release. Please let us know if you want to be credited.
+68 -1
View File
@@ -1,2 +1,69 @@
# Pre-release Todos
# Todo
## 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'),
);
}
```
+52 -121
View File
@@ -1,74 +1,6 @@
# Changelog
All notable changes to this project will be documented in this file.
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]
### Added
- You can now use `$smarty->muteUndefinedOrNullWarnings()` to activate convert warnings about undefined or null template vars to notices when running PHP8
### Changed
- Switch CI from Travis to Github CI
- Updated unit tests to avoid skipped and risky test warnings
### Removed
- Dropped support for PHP7.0 and below, so Smarty now requires PHP >=7.1
- Dropped support for php asp tags in templates (removed from php since php7.0)
- Dropped deprecated API calls that where only accessible through SmartyBC
- Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is.
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
- Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants
- Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods
- Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead.
- $smarty->registerResource() no longer accepts an array of callback functions
## [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
===== 3.1.34 release ===== 05.11.2019
13.01.2020
- fix typo in exception message (JercSi)
- fix typehint warning with callable (bets4breakfast)
@@ -77,8 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -106,8 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -129,14 +60,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -148,7 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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.
@@ -289,7 +220,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -403,7 +334,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -626,7 +557,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -662,7 +593,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -841,18 +772,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -882,7 +813,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -920,12 +851,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1077,7 +1008,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1100,7 +1031,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1120,7 +1051,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1147,7 +1078,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1176,7 +1107,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1207,7 +1138,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1240,7 +1171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1304,7 +1235,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1337,7 +1268,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1368,7 +1299,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1413,7 +1344,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1426,12 +1357,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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)
@@ -1485,7 +1416,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1532,7 +1463,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1557,7 +1488,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1582,7 +1513,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1614,7 +1545,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1643,7 +1574,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
@@ -1670,7 +1601,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1710,7 +1641,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -1743,7 +1674,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -1836,7 +1767,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -2037,7 +1968,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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
@@ -2097,7 +2028,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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}
@@ -2151,7 +2082,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -2186,7 +2117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -2213,7 +2144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -2226,7 +2157,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(introduced with 3.0.2)
- code cleanup
## Smarty 3.0.3 -
===== Smarty 3.0.3 =====
13/11/2010
- bugfix on {debug}
@@ -2235,7 +2166,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
@@ -2245,7 +2176,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
with transparent access to Smarty object
- fixed {config_load} scoping form compile time to run time
## Smarty 3.0.0 -
===== Smarty 3.0.0 =====
@@ -2287,7 +2218,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
@@ -2384,7 +2315,7 @@ request_use_auto_globals
15/07/2010
- bufix {$smarty.template} does include now the relative path, not just filename
## RC3 -
===== RC3 =====
@@ -2438,7 +2369,7 @@ request_use_auto_globals
- make handling of Smarty comments followed by newline BC to Smarty2
## RC2 -
===== RC2 =====
@@ -2510,7 +2441,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'
+6 -10
View File
@@ -5,7 +5,7 @@
"keywords": [
"templating"
],
"homepage": "https://www.smarty.net",
"homepage": "http://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
{
@@ -19,18 +19,15 @@
{
"name": "Rodney Rehm",
"email": "rodney.rehm@medialize.de"
},
{
"name": "Simon Wisselink",
"homepage": "https://www.iwink.nl/"
}
],
"support": {
"irc": "irc://irc.freenode.org/smarty",
"issues": "https://github.com/smarty-php/smarty/issues",
"forum": "https://www.smarty.net/forums/"
"forum": "http://www.smarty.net/forums/"
},
"require": {
"php": "^7.1 || ^8.0"
"php": ">=5.2"
},
"autoload": {
"classmap": [
@@ -39,11 +36,10 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-master": "3.1.x-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^7.5",
"smarty/smarty-lexer": "^3.1"
"phpunit/phpunit": "6.4.1"
}
}
+1
View File
@@ -0,0 +1 @@
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
+9 -1
View File
@@ -289,6 +289,8 @@ class Smarty_Internal_Templatelexer
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
emptyjava = ~[{][}]~
phptag = ~(SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[/]phpSMARTYrdel~
phpstart = ~[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]~
slash = ~[/]~
ldel = ~(SMARTYldel)SMARTYal~
rdel = ~\s*SMARTYrdel~
@@ -360,6 +362,9 @@ class Smarty_Internal_Templatelexer
$this->value = substr($this->data,$this->counter,$to-$this->counter);
return false;
}
phptag {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
userliteral {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
@@ -375,9 +380,12 @@ class Smarty_Internal_Templatelexer
$this->yypushstate(self::TAG);
return true;
}
phpstart {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
char {
if (!isset($this->yy_global_text)) {
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS');
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*[>]|[?][>]|[%][>]SMARTYliteral/isS');
}
$to = $this->dataLength;
preg_match($this->yy_global_text, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
+13 -8
View File
@@ -23,6 +23,7 @@ class Smarty_Internal_Templateparser
{
const ERR1 = 'Security error: Call to private object member not allowed';
const ERR2 = 'Security error: Call to dynamic object member not allowed';
const ERR3 = 'PHP in template not allowed. Use SmartyBC to enable it';
/**
* result status
@@ -236,15 +237,19 @@ start(res) ::= template. {
res = $this->root_buffer->to_smarty_php($this);
}
// php tags
template ::= template PHP(B). {
$code = $this->compiler->compileTag('private_php',array(array('code' => B), array('type' => $this->lex->phpType )),array());
if ($this->compiler->has_code && !empty($code)) {
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true)));
}
}
// template text
template ::= template TEXT(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));
$this->current_buffer->append_subtree($this, $this->compiler->processText(B));
}
// strip on
template ::= template STRIPON. {
@@ -303,7 +308,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) {
+6 -2
View File
@@ -39,7 +39,7 @@ class Smarty_Autoloader
*
* @var array
*/
public static $rootClasses = array('smarty' => 'Smarty.class.php');
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
/**
* Registers Smarty_Autoloader backward compatible to older installations.
@@ -76,7 +76,11 @@ class Smarty_Autoloader
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(__CLASS__, 'autoload'));
}
}
/**
+60 -32
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 3.0 of the License, or (at your option) any later version.
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,13 +20,14 @@
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link https://www.smarty.net/
* @link http://www.smarty.net/
* @copyright 2018 New Digital Group, Inc.
* @copyright 2018 Uwe Tews
* @author Monte Ohrt <monte at ohrt dot com>
* @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.
@@ -60,6 +61,19 @@ if (!defined('SMARTY_MBSTRING')) {
*/
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
}
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
// UTF-8 can only be done properly when mbstring is available!
/**
* @deprecated in favor of Smarty::$_CHARSET
*/
define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
}
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
/**
* @deprecated in favor of Smarty::$_DATE_FORMAT
*/
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
}
/**
* Load Smarty_Autoloader
*/
@@ -98,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.40';
const SMARTY_VERSION = '3.1.34-dev-7';
/**
* define variable scopes
*/
@@ -130,7 +144,13 @@ class Smarty extends Smarty_Internal_TemplateBase
const DEBUG_OFF = 0;
const DEBUG_ON = 1;
const DEBUG_INDIVIDUAL = 2;
/**
* modes for handling of "<?php ... ?>" tags in templates.
*/
const PHP_PASSTHRU = 0; //-> print tags as plain text
const PHP_QUOTE = 1; //-> escape tags as entities
const PHP_REMOVE = 2; //-> escape tags as entities
const PHP_ALLOW = 3; //-> escape tags as entities
/**
* filter types
*/
@@ -160,13 +180,13 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = '%b %e, %Y';
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/**
* Flag denoting if PCRE should run in UTF-8 mode
@@ -350,6 +370,13 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public $security_policy = null;
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
/**
* controls if the php template file resource is allowed
*
@@ -640,12 +667,6 @@ class Smarty extends Smarty_Internal_TemplateBase
'cache_dir' => 'CacheDir',
);
/**
* PHP7 Compatibility mode
* @var bool
*/
private $isMutingUndefinedOrNullWarnings = false;
/**
* Initialize new Smarty object
*/
@@ -668,6 +689,27 @@ class Smarty extends Smarty_Internal_TemplateBase
}
}
/**
* Enable error handler to mute expected messages
*
* @return boolean
* @deprecated
*/
public static function muteExpectedErrors()
{
return Smarty_Internal_ErrorHandler::muteExpectedErrors();
}
/**
* Disable error handler muting expected messages
*
* @deprecated
*/
public static function unmuteExpectedErrors()
{
restore_error_handler();
}
/**
* Check if a template resource exists
*
@@ -758,7 +800,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|string list of template directories, or directory of $index
* @return array list of template directories, or directory of $index
*/
public function getTemplateDir($index = null, $isConfig = false)
{
@@ -1346,6 +1388,11 @@ class Smarty extends Smarty_Internal_TemplateBase
private function _normalizeDir($dirName, $dir)
{
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
if (class_exists('Smarty_Internal_ErrorHandler', false)) {
if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
}
}
}
/**
@@ -1375,23 +1422,4 @@ class Smarty extends Smarty_Internal_TemplateBase
$isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
$this->_joined_template_dir = join('#', $this->template_dir);
}
/**
* Activates PHP7 compatibility mode:
* - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE
*
* @void
*/
public function muteUndefinedOrNullWarnings(): void {
$this->isMutingUndefinedOrNullWarnings = true;
}
/**
* Indicates if PHP7 compatibility mode is set.
* @bool
*/
public function isMutingUndefinedOrNullWarnings(): bool {
return $this->isMutingUndefinedOrNullWarnings;
}
}
+477
View File
@@ -0,0 +1,477 @@
<?php
/**
* Project: Smarty: the PHP compiling template engine
* File: SmartyBC.class.php
* SVN: $Id: $
* 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.
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @copyright 2008 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
*/
/**
* @ignore
*/
require_once dirname(__FILE__) . '/Smarty.class.php';
/**
* Smarty Backward Compatibility Wrapper Class
*
* @package Smarty
*/
class SmartyBC extends Smarty
{
/**
* Smarty 2 BC
*
* @var string
*/
public $_version = self::SMARTY_VERSION;
/**
* This is an array of directories where trusted php scripts reside.
*
* @var array
*/
public $trusted_dir = array();
/**
* Initialize new SmartyBC object
*/
public function __construct()
{
parent::__construct();
}
/**
* wrapper for assign_by_ref
*
* @param string $tpl_var the template variable name
* @param mixed &$value the referenced value to assign
*/
public function assign_by_ref($tpl_var, &$value)
{
$this->assignByRef($tpl_var, $value);
}
/**
* wrapper for append_by_ref
*
* @param string $tpl_var the template variable name
* @param mixed &$value the referenced value to append
* @param boolean $merge flag if array elements shall be merged
*/
public function append_by_ref($tpl_var, &$value, $merge = false)
{
$this->appendByRef($tpl_var, $value, $merge);
}
/**
* clear the given assigned template variable.
*
* @param string $tpl_var the template variable to clear
*/
public function clear_assign($tpl_var)
{
$this->clearAssign($tpl_var);
}
/**
* Registers custom function to be used in templates
*
* @param string $function the name of the template function
* @param string $function_impl the name of the PHP function to register
* @param bool $cacheable
* @param mixed $cache_attrs
*
* @throws \SmartyException
*/
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
{
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
}
/**
* Unregister custom function
*
* @param string $function name of template function
*/
public function unregister_function($function)
{
$this->unregisterPlugin('function', $function);
}
/**
* Registers object to be used in templates
*
* @param string $object name of template object
* @param object $object_impl the referenced PHP object to register
* @param array $allowed list of allowed methods (empty = all)
* @param boolean $smarty_args smarty argument format, else traditional
* @param array $block_methods list of methods that are block format
*
* @throws SmartyException
* @internal param array $block_functs list of methods that are block format
*/
public function register_object(
$object,
$object_impl,
$allowed = array(),
$smarty_args = true,
$block_methods = array()
) {
settype($allowed, 'array');
settype($smarty_args, 'boolean');
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
}
/**
* Unregister object
*
* @param string $object name of template object
*/
public function unregister_object($object)
{
$this->unregisterObject($object);
}
/**
* Registers block function to be used in templates
*
* @param string $block name of template block
* @param string $block_impl PHP function to register
* @param bool $cacheable
* @param mixed $cache_attrs
*
* @throws \SmartyException
*/
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
{
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
}
/**
* Unregister block function
*
* @param string $block name of template function
*/
public function unregister_block($block)
{
$this->unregisterPlugin('block', $block);
}
/**
* Registers compiler function
*
* @param string $function name of template function
* @param string $function_impl name of PHP function to register
* @param bool $cacheable
*
* @throws \SmartyException
*/
public function register_compiler_function($function, $function_impl, $cacheable = true)
{
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
}
/**
* Unregister compiler function
*
* @param string $function name of template function
*/
public function unregister_compiler_function($function)
{
$this->unregisterPlugin('compiler', $function);
}
/**
* Registers modifier to be used in templates
*
* @param string $modifier name of template modifier
* @param string $modifier_impl name of PHP function to register
*
* @throws \SmartyException
*/
public function register_modifier($modifier, $modifier_impl)
{
$this->registerPlugin('modifier', $modifier, $modifier_impl);
}
/**
* Unregister modifier
*
* @param string $modifier name of template modifier
*/
public function unregister_modifier($modifier)
{
$this->unregisterPlugin('modifier', $modifier);
}
/**
* Registers a resource to fetch a template
*
* @param string $type name of resource
* @param array $functions array of functions to handle resource
*/
public function register_resource($type, $functions)
{
$this->registerResource($type, $functions);
}
/**
* Unregister a resource
*
* @param string $type name of resource
*/
public function unregister_resource($type)
{
$this->unregisterResource($type);
}
/**
* Registers a prefilter function to apply
* to a template before compiling
*
* @param callable $function
*
* @throws \SmartyException
*/
public function register_prefilter($function)
{
$this->registerFilter('pre', $function);
}
/**
* Unregister a prefilter function
*
* @param callable $function
*/
public function unregister_prefilter($function)
{
$this->unregisterFilter('pre', $function);
}
/**
* Registers a postfilter function to apply
* to a compiled template after compilation
*
* @param callable $function
*
* @throws \SmartyException
*/
public function register_postfilter($function)
{
$this->registerFilter('post', $function);
}
/**
* Unregister a postfilter function
*
* @param callable $function
*/
public function unregister_postfilter($function)
{
$this->unregisterFilter('post', $function);
}
/**
* Registers an output filter function to apply
* to a template output
*
* @param callable $function
*
* @throws \SmartyException
*/
public function register_outputfilter($function)
{
$this->registerFilter('output', $function);
}
/**
* Unregister an outputfilter function
*
* @param callable $function
*/
public function unregister_outputfilter($function)
{
$this->unregisterFilter('output', $function);
}
/**
* load a filter of specified type and name
*
* @param string $type filter type
* @param string $name filter name
*
* @throws \SmartyException
*/
public function load_filter($type, $name)
{
$this->loadFilter($type, $name);
}
/**
* clear cached content for the given template and cache id
*
* @param string $tpl_file name of template file
* @param string $cache_id name of cache_id
* @param string $compile_id name of compile_id
* @param string $exp_time expiration time
*
* @return boolean
*/
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
}
/**
* clear the entire contents of cache (all templates)
*
* @param string $exp_time expire time
*
* @return boolean
*/
public function clear_all_cache($exp_time = null)
{
return $this->clearCache(null, null, null, $exp_time);
}
/**
* test to see if valid cache exists for this template
*
* @param string $tpl_file name of template file
* @param string $cache_id
* @param string $compile_id
*
* @return bool
* @throws \Exception
* @throws \SmartyException
*/
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
{
return $this->isCached($tpl_file, $cache_id, $compile_id);
}
/**
* clear all the assigned template variables.
*/
public function clear_all_assign()
{
$this->clearAllAssign();
}
/**
* clears compiled version of specified template resource,
* or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed.
*
* @param string $tpl_file
* @param string $compile_id
* @param string $exp_time
*
* @return boolean results of {@link smarty_core_rm_auto()}
*/
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
{
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
}
/**
* Checks whether requested template exists.
*
* @param string $tpl_file
*
* @return bool
* @throws \SmartyException
*/
public function template_exists($tpl_file)
{
return $this->templateExists($tpl_file);
}
/**
* Returns an array containing template variables
*
* @param string $name
*
* @return array
*/
public function get_template_vars($name = null)
{
return $this->getTemplateVars($name);
}
/**
* Returns an array containing config variables
*
* @param string $name
*
* @return array
*/
public function get_config_vars($name = null)
{
return $this->getConfigVars($name);
}
/**
* load configuration values
*
* @param string $file
* @param string $section
* @param string $scope
*/
public function config_load($file, $section = null, $scope = 'global')
{
$this->ConfigLoad($file, $section, $scope);
}
/**
* return a reference to a registered object
*
* @param string $name
*
* @return object
*/
public function get_registered_object($name)
{
return $this->getRegisteredObject($name);
}
/**
* clear configuration values
*
* @param string $var
*/
public function clear_config($var = null)
{
$this->clearConfig($var);
}
/**
* trigger Smarty error
*
* @param string $error_msg
* @param integer $error_type
*/
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
{
trigger_error("Smarty error: $error_msg", $error_type);
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
* @link https://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
* @param array $params parameters
+1 -1
View File
@@ -12,7 +12,7 @@
* Purpose: print out a counter value
*
* @author Monte Ohrt <monte at ohrt dot com>
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
*
* @param array $params parameters
+1 -1
View File
@@ -28,7 +28,7 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
* @link https://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <mpriatel@rogers.com>
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: fetch
* Purpose: fetch file, web or ftp data and display results
*
* @link https://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
+1 -1
View File
@@ -29,7 +29,7 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
* @link https://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
+1 -1
View File
@@ -21,7 +21,7 @@
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
* - path_prefix - prefix for path output (optional, default empty)
*
* @link https://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu>
+1 -1
View File
@@ -21,7 +21,7 @@
* - id (optional) - string default not set
* - class (optional) - string default not set
*
* @link https://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
+1 -1
View File
@@ -29,7 +29,7 @@
* {html_radios values=$ids name='box' separator='<br>' output=$names}
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
*
* @link https://www.smarty.net/manual/en/language.function.html.radios.php {html_radios}
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
+1 -1
View File
@@ -28,7 +28,7 @@
* - 2.0 complete rewrite for performance,
* added attributes month_names, *_id
*
* @link https://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
* @author Andrei Zmievski
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: html_select_time
* Purpose: Prints the dropdowns for time selection
*
* @link https://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual)
* @author Roberto Berto <roberto@berto.net>
* @author Monte Ohrt <monte AT ohrt DOT com>
+1 -1
View File
@@ -38,7 +38,7 @@
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com>
* @version 1.1
* @link https://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
*
* @param array $params parameters
+1 -1
View File
@@ -36,7 +36,7 @@
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
*
* @link https://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
* @version 1.2
* @author Monte Ohrt <monte at ohrt dot com>
+1 -1
View File
@@ -12,7 +12,7 @@
* Name: math
* Purpose: handle math computations in template
*
* @link https://www.smarty.net/manual/en/language.function.math.php {math}
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
+1 -1
View File
@@ -15,7 +15,7 @@
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @link https://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input date string
+6 -8
View File
@@ -11,7 +11,7 @@
* Name: escape
* Purpose: escape string for output
*
* @link https://www.smarty.net/docs/en/language.modifier.escape
* @link http://www.smarty.net/docs/en/language.modifier.escape
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
@@ -23,9 +23,12 @@
*/
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
{
static $_double_encode = true;
static $_double_encode = null;
static $is_loaded_1 = false;
static $is_loaded_2 = false;
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}
if (!$char_set) {
$char_set = Smarty::$_CHARSET;
}
@@ -181,11 +184,7 @@ 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':
@@ -251,7 +250,6 @@ 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;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: mb_wordwrap
* Purpose: Wrap a string to a given number of characters
*
* @link https://php.net/manual/en/function.wordwrap.php for similarity
* @link http://php.net/manual/en/function.wordwrap.php for similarity
*
* @param string $str the string to wrap
* @param int $width the width of the output
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: regex_replace
* Purpose: regular expression search/replace
*
* @link https://www.smarty.net/manual/en/language.modifier.regex.replace.php
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
* regex_replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: replace
* Purpose: simple search/replace
*
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: spacify
* Purpose: add spaces between characters in a string
*
* @link https://www.smarty.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
+1 -1
View File
@@ -13,7 +13,7 @@
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
*
* @link https://www.smarty.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
+1 -1
View File
@@ -14,7 +14,7 @@
* Input: string to catenate
* Example: {$var|cat:"foo"}
*
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
* (Smarty online manual)
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: count_characters
* Purpose: count the number of characters in a text
*
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* manual)
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: count_paragraphs
* Purpose: count the number of paragraphs in a text
*
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual)
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: count_sentences
* Purpose: count the number of sentences in a text
*
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual)
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: count_words
* Purpose: count the number of words in a text
*
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+2 -2
View File
@@ -11,7 +11,7 @@
* Name: default
* Purpose: designate default value for empty variables
*
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
@@ -26,7 +26,7 @@ function smarty_modifiercompiler_default($params)
}
array_shift($params);
foreach ($params as $param) {
$output = '(($tmp = ' . $output . ' ?? null)===null||$tmp===\'\' ? ' . $param . ' ?? null : $tmp)';
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
}
return $output;
}
+6 -4
View File
@@ -11,7 +11,7 @@
* Name: escape
* Purpose: escape string for output
*
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @author Rodney Rehm
*
* @param array $params parameters
@@ -22,7 +22,7 @@
*/
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
{
static $_double_encode = true;
static $_double_encode = null;
static $is_loaded = false;
$compiler->template->_checkPlugins(
array(
@@ -32,6 +32,9 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
)
)
);
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}
try {
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
@@ -86,10 +89,9 @@ 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", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
}
} catch (SmartyException $e) {
// pass through to regular plugin fallback
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: indent
* Purpose: indent lines of text
*
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: lower
* Purpose: convert string to lowercase
*
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: string_format
* Purpose: format strings via sprintf
*
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -14,7 +14,7 @@
* Example: {$var|strip} {$var|strip:"&nbsp;"}
* Date: September 25th, 2002
*
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: strip_tags
* Purpose: strip html tags from text
*
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
* @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: lower
* Purpose: convert string to uppercase
*
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: wordwrap
* Purpose: wrap a string of text at a given length
*
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -1
View File
@@ -41,7 +41,7 @@ function smarty_outputfilter_trimwhitespace($source)
}
}
// Strip all HTML-Comments
// yes, even the ones in <script> - see https://stackoverflow.com/a/808850/515124
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
$source = preg_replace('#<!--.*?-->#ms', '', $source);
// capture html elements not to be messed with
$_offset = 0;
+7 -1
View File
@@ -20,7 +20,13 @@
function smarty_function_escape_special_chars($string)
{
if (!is_array($string)) {
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
} else {
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
}
}
return $string;
}
@@ -196,7 +196,11 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
clearstatcache(true, $cached->lock_id);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
clearstatcache(true, $cached->lock_id);
} else {
clearstatcache();
}
if (is_file($cached->lock_id)) {
$t = filemtime($cached->lock_id);
return $t && (time() - $t < $smarty->locking_timeout);
@@ -219,9 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
if (isset($itemAttr[ 'index' ])) {
$output .= "{$itemVar}->index = -1;\n";
}
$output .= "{$itemVar}->do_else = true;\n";
$output .= "{$itemVar}->do_else = true;\n";
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
$output .= "{$itemVar}->do_else = false;\n";
$output .= "{$itemVar}->do_else = false;\n";
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
}
@@ -58,11 +58,6 @@ 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,
@@ -0,0 +1,110 @@
<?php
/**
* Smarty Internal Plugin Compile Include PHP
* Compiles the {include_php} tag
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile Insert Class
*
* @package Smarty
* @subpackage Compiler
*/
class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
{
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('file');
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('once', 'assign');
/**
* Compiles code for the {include_php} tag
*
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string
* @throws \SmartyCompilerException
* @throws \SmartyException
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
if (!($compiler->smarty instanceof SmartyBC)) {
throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
}
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
/**
*
*
* @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $compiler->template;
$_filepath = false;
$_file = null;
eval('$_file = @' . $_attr[ 'file' ] . ';');
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
$_filepath = $compiler->smarty->_realpath($_file, true);
} else {
if (isset($compiler->smarty->security_policy)) {
$_dir = $compiler->smarty->security_policy->trusted_dir;
} else {
$_dir = $compiler->smarty->trusted_dir;
}
if (!empty($_dir)) {
foreach ((array)$_dir as $_script_dir) {
$_path = $compiler->smarty->_realpath($_script_dir . DIRECTORY_SEPARATOR . $_file, true);
if (file_exists($_path)) {
$_filepath = $_path;
break;
}
}
}
}
if ($_filepath === false) {
$compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
}
if (isset($compiler->smarty->security_policy)) {
$compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
}
if (isset($_attr[ 'assign' ])) {
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr[ 'assign' ];
}
$_once = '_once';
if (isset($_attr[ 'once' ])) {
if ($_attr[ 'once' ] === 'false') {
$_once = '';
}
}
if (isset($_assign)) {
return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
} else {
return "<?php include{$_once} ('{$_filepath}');?>\n";
}
}
}
@@ -89,7 +89,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
if (isset($compiler->smarty->security_policy)) {
$_dir = $compiler->smarty->security_policy->trusted_dir;
} else {
$_dir = null;
$_dir = $compiler->smarty instanceof SmartyBC ? $compiler->smarty->trusted_dir : null;
}
if (!empty($_dir)) {
foreach ((array)$_dir as $_script_dir) {
@@ -0,0 +1,253 @@
<?php
/**
* Smarty Internal Plugin Compile PHP Expression
* Compiles any tag which will output an expression or variable
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile PHP Expression Class
*
* @package Smarty
* @subpackage Compiler
*/
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
{
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('code', 'type');
/**
* Compiles code for generating output from any expression
*
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param array $parameter array with compilation parameter
*
* @return string
* @throws \SmartyException
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$compiler->has_code = false;
if ($_attr[ 'type' ] === 'xml') {
$compiler->tag_nocache = true;
$output = addcslashes($_attr[ 'code' ], "'\\");
$compiler->parser->current_buffer->append_subtree(
$compiler->parser,
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>\n",
true
)
)
);
return '';
}
if ($_attr[ 'type' ] !== 'tag') {
if ($compiler->php_handling === Smarty::PHP_REMOVE) {
return '';
} elseif ($compiler->php_handling === Smarty::PHP_QUOTE) {
$output =
preg_replace_callback(
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
array($this, 'quote'),
$_attr[ 'code' ]
);
$compiler->parser->current_buffer->append_subtree(
$compiler->parser,
new Smarty_Internal_ParseTree_Text($output)
);
return '';
} elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') {
$compiler->tag_nocache = true;
$output = addcslashes($_attr[ 'code' ], "'\\");
$compiler->parser->current_buffer->append_subtree(
$compiler->parser,
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>\n",
true
)
)
);
return '';
} elseif ($compiler->php_handling === Smarty::PHP_ALLOW) {
if (!($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error(
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
null,
true
);
}
$compiler->has_code = true;
return $_attr[ 'code' ];
} else {
$compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
}
} else {
$compiler->has_code = true;
if (!($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error(
'{php}{/php} tags not allowed. Use SmartyBC to enable them',
null,
true
);
}
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match);
if (!empty($match[ 2 ])) {
if ('nocache' === trim($match[ 2 ])) {
$compiler->tag_nocache = true;
} else {
$compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true);
}
}
return preg_replace(
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
array('<?php ', '?>'),
$_attr[ 'code' ]
);
}
}
/**
* Lexer code for PHP tags
*
* This code has been moved from lexer here fo easier debugging and maintenance
*
* @param Smarty_Internal_Templatelexer $lex
*
* @throws \SmartyCompilerException
*/
public function parsePhp(Smarty_Internal_Templatelexer $lex)
{
$lex->token = Smarty_Internal_Templateparser::TP_PHP;
$close = 0;
$lex->taglineno = $lex->line;
$closeTag = '?>';
if (strpos($lex->value, '<?xml') === 0) {
$lex->is_xml = true;
$lex->phpType = 'xml';
return;
} elseif (strpos($lex->value, '<?') === 0) {
$lex->phpType = 'php';
} elseif (strpos($lex->value, '<%') === 0) {
$lex->phpType = 'asp';
$closeTag = '%>';
} elseif (strpos($lex->value, '%>') === 0) {
$lex->phpType = 'unmatched';
} elseif (strpos($lex->value, '?>') === 0) {
if ($lex->is_xml) {
$lex->is_xml = false;
$lex->phpType = 'xml';
return;
}
$lex->phpType = 'unmatched';
} elseif (strpos($lex->value, '<s') === 0) {
$lex->phpType = 'script';
$closeTag = '</script>';
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
if ($lex->isAutoLiteral()) {
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
return;
}
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
if ($lex->value === $closeTag) {
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
}
$lex->phpType = 'tag';
}
if ($lex->phpType === 'unmatched') {
return;
}
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
&&
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
) {
return;
}
$start = $lex->counter + strlen($lex->value);
$body = true;
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
$close = $match[ 0 ][ 1 ];
} else {
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
}
while ($body) {
if (preg_match(
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
$lex->data,
$match,
PREG_OFFSET_CAPTURE,
$start
)
) {
$value = $match[ 0 ][ 0 ];
$from = $pos = $match[ 0 ][ 1 ];
if ($pos > $close) {
$body = false;
} else {
$start = $pos + strlen($value);
$phpCommentStart = $value === '/*';
if ($phpCommentStart) {
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
if ($phpCommentEnd) {
$pos2 = $match[ 0 ][ 1 ];
$start = $pos2 + strlen($match[ 0 ][ 0 ]);
}
}
while ($close > $pos && $close < $start) {
if (preg_match(
'~' . preg_quote($closeTag, '~') . '~i',
$lex->data,
$match,
PREG_OFFSET_CAPTURE,
$from
)
) {
$close = $match[ 0 ][ 1 ];
$from = $close + strlen($match[ 0 ][ 0 ]);
} else {
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
}
}
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
}
}
} else {
$body = false;
}
}
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
}
/*
* Call back function for $php_handling = PHP_QUOTE
*
*/
/**
* @param $match
*
* @return string
*/
private function quote($match)
{
return htmlspecialchars($match[ 0 ], ENT_QUOTES);
}
}
@@ -81,10 +81,6 @@ 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)';
@@ -98,9 +94,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
break;
}
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
return "(defined('{$_index[1]}') ? constant('{$_index[1]}') : null)";
return "@constant('{$_index[1]}')";
} else {
return "(defined({$_index[1]}) ? constant({$_index[1]}) : null)";
return "@constant({$_index[1]})";
}
// 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')
+22 -2
View File
@@ -121,7 +121,7 @@ abstract class Smarty_Internal_Data
* appends values to template variables
*
* @api Smarty::append()
* @link https://www.smarty.net/docs/en/api.append.tpl
* @link http://www.smarty.net/docs/en/api.append.tpl
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to append
@@ -182,7 +182,7 @@ abstract class Smarty_Internal_Data
* Returns a single or all template variables
*
* @api Smarty::getTemplateVars()
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
*
* @param string $varName variable name or null
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
@@ -195,6 +195,26 @@ abstract class Smarty_Internal_Data
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
}
/**
* gets the object of a Smarty variable
*
* @param string $variable the name of the Smarty variable
* @param Smarty_Internal_Data $_ptr optional pointer to data object
* @param boolean $searchParents search also in parent data
* @param bool $error_enable
*
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
*/
public function getVariable(
$variable = null,
Smarty_Internal_Data $_ptr = null,
$searchParents = true,
$error_enable = true
) {
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
}
/**
* Follow the parent chain an merge template and config variables
*
@@ -1,60 +1,61 @@
<?php
/**
* Smarty error handler to fix new error levels in PHP8 for backwards compatibility
* Smarty error handler
*
* @package Smarty
* @subpackage PluginsInternal
* @author Simon Wisselink
* @author Uwe Tews
*
* @deprecated
Smarty does no longer use @filemtime()
*/
class Smarty_Internal_ErrorHandler
{
/**
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
*/
public static $mutedDirectories = array();
/**
* Allows {$foo} where foo is unset.
* @var bool
* error handler returned by set_error_handler() in self::muteExpectedErrors()
*/
public $allowUndefinedVars = true;
private static $previousErrorHandler = null;
/**
* Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset.
* @var bool
* Enable error handler to mute expected messages
*
*/
public $allowUndefinedArrayKeys = true;
private $previousErrorHandler = null;
/**
* Enable error handler to intercept errors
*/
public function activate() {
public static function muteExpectedErrors()
{
/*
Error muting is done because some people implemented custom error_handlers using
https://php.net/set_error_handler and for some reason did not understand the following paragraph:
error muting is done because some people implemented custom error_handlers using
http://php.net/set_error_handler and for some reason did not understand the following paragraph:
It is important to remember that the standard PHP error handler is completely bypassed for the
error types specified by error_types unless the callback function returns FALSE.
error_reporting() settings will have no effect and your error handler will be called regardless -
however you are still able to read the current value of error_reporting and act appropriately.
Of particular note is that this value will be 0 if the statement that caused the error was
prepended by the @ error-control operator.
It is important to remember that the standard PHP error handler is completely bypassed for the
error types specified by error_types unless the callback function returns FALSE.
error_reporting() settings will have no effect and your error handler will be called regardless -
however you are still able to read the current value of error_reporting and act appropriately.
Of particular note is that this value will be 0 if the statement that caused the error was
prepended by the @ error-control operator.
Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include
- @filemtime() is almost twice as fast as using an additional file_exists()
- between file_exists() and filemtime() a possible race condition is opened,
which does not exist using the simple @filemtime() approach.
*/
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
}
/**
* Disable error handler
*/
public function deactivate() {
restore_error_handler();
$this->previousErrorHandler = null;
$error_handler = array('Smarty_Internal_ErrorHandler', 'mutingErrorHandler');
$previous = set_error_handler($error_handler);
// avoid dead loops
if ($previous !== $error_handler) {
self::$previousErrorHandler = $previous;
}
}
/**
* Error Handler to mute expected messages
*
* @link https://php.net/set_error_handler
* @link http://php.net/set_error_handler
*
* @param integer $errno Error level
* @param $errstr
@@ -64,21 +65,49 @@ class Smarty_Internal_ErrorHandler
*
* @return bool
*/
public function handleError($errno, $errstr, $errfile, $errline, $errcontext = [])
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
if ($this->allowUndefinedVars && $errstr == 'Attempt to read property "value" on null') {
return; // suppresses this error
$_is_muted_directory = false;
// add the SMARTY_DIR to the list of muted directories
if (!isset(self::$mutedDirectories[ SMARTY_DIR ])) {
$smarty_dir = realpath(SMARTY_DIR);
if ($smarty_dir !== false) {
self::$mutedDirectories[ SMARTY_DIR ] =
array('file' => $smarty_dir, 'length' => strlen($smarty_dir),);
}
}
if ($this->allowUndefinedArrayKeys && preg_match(
'/^(Undefined array key|Trying to access array offset on value of type null)/',
$errstr
)) {
return; // suppresses this error
// walk the muted directories and test against $errfile
foreach (self::$mutedDirectories as $key => &$dir) {
if (!$dir) {
// resolve directory and length for speedy comparisons
$file = realpath($key);
if ($file === false) {
// this directory does not exist, remove and skip it
unset(self::$mutedDirectories[ $key ]);
continue;
}
$dir = array('file' => $file, 'length' => strlen($file),);
}
if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) {
$_is_muted_directory = true;
break;
}
}
// pass to next error handler if this error did not occur inside SMARTY_DIR
// or the error was within smarty but masked to be ignored
if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
if (self::$previousErrorHandler) {
return call_user_func(
self::$previousErrorHandler,
$errno,
$errstr,
$errfile,
$errline,
$errcontext
);
} else {
return false;
}
}
// pass all other errors through to the previous error handler or to the default PHP error handler
return $this->previousErrorHandler ?
call_user_func($this->previousErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext) : false;
}
}
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_Append
* appends values to template variables
*
* @api Smarty::append()
* @link https://www.smarty.net/docs/en/api.append.tpl
* @link http://www.smarty.net/docs/en/api.append.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param array|string $tpl_var the template variable name(s)
@@ -15,7 +15,7 @@ class Smarty_Internal_Method_AppendByRef
* appends values to template variables by reference
*
* @api Smarty::appendByRef()
* @link https://www.smarty.net/docs/en/api.append.by.ref.tpl
* @link http://www.smarty.net/docs/en/api.append.by.ref.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $tpl_var the template variable name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllAssign
* clear all the assigned template variables.
*
* @api Smarty::clearAllAssign()
* @link https://www.smarty.net/docs/en/api.clear.all.assign.tpl
* @link http://www.smarty.net/docs/en/api.clear.all.assign.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
*
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllCache
* Empty cache folder
*
* @api Smarty::clearAllCache()
* @link https://www.smarty.net/docs/en/api.clear.all.cache.tpl
* @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
*
* @param \Smarty $smarty
* @param integer $exp_time expiration time
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAssign
* clear the given assigned template variable(s).
*
* @api Smarty::clearAssign()
* @link https://www.smarty.net/docs/en/api.clear.assign.tpl
* @link http://www.smarty.net/docs/en/api.clear.assign.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string|array $tpl_var the template variable(s) to clear
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCache
* Empty cache for a specific template
*
* @api Smarty::clearCache()
* @link https://www.smarty.net/docs/en/api.clear.cache.tpl
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
*
* @param \Smarty $smarty
* @param string $template_name template name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
* Delete compiled template file
*
* @api Smarty::clearCompiledTemplate()
* @link https://www.smarty.net/docs/en/api.clear.compiled.template.tpl
* @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
*
* @param \Smarty $smarty
* @param string $resource_name template name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearConfig
* clear a single or all config variables
*
* @api Smarty::clearConfig()
* @link https://www.smarty.net/docs/en/api.clear.config.tpl
* @link http://www.smarty.net/docs/en/api.clear.config.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string|null $name variable name or null
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ConfigLoad
* load a config file, optionally load just selected sections
*
* @api Smarty::configLoad()
* @link https://www.smarty.net/docs/en/api.config.load.tpl
* @link http://www.smarty.net/docs/en/api.config.load.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $config_file filename
@@ -42,7 +42,7 @@ class Smarty_Internal_Method_ConfigLoad
* load a config file, optionally load just selected sections
*
* @api Smarty::configLoad()
* @link https://www.smarty.net/docs/en/api.config.load.tpl
* @link http://www.smarty.net/docs/en/api.config.load.tpl
*
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
* @param string $config_file filename
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_CreateData
* creates a data object
*
* @api Smarty::createData()
* @link https://www.smarty.net/docs/en/api.create.data.tpl
* @link http://www.smarty.net/docs/en/api.create.data.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetConfigVars
* Returns a single or all config variables
*
* @api Smarty::getConfigVars()
* @link https://www.smarty.net/docs/en/api.get.config.vars.tpl
* @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $varname variable name or null
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetRegisteredObject
* return a reference to a registered object
*
* @api Smarty::getRegisteredObject()
* @link https://www.smarty.net/docs/en/api.get.registered.object.tpl
* @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name object name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTags
* Return array of tag/attributes of all tags used by an template
*
* @api Smarty::getTags()
* @link https://www.smarty.net/docs/en/api.get.tags.tpl
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param null|string|Smarty_Internal_Template $template
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTemplateVars
* Returns a single or all template variables
*
* @api Smarty::getTemplateVars()
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $varName variable name or null
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_LoadFilter
*
* @api Smarty::loadFilter()
*
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterCacheResource
* Registers a resource to fetch a template
*
* @api Smarty::registerCacheResource()
* @link https://www.smarty.net/docs/en/api.register.cacheresource.tpl
* @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $name name of resource type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterClass
* Registers static classes to be used in templates
*
* @api Smarty::registerClass()
* @link https://www.smarty.net/docs/en/api.register.class.tpl
* @link http://www.smarty.net/docs/en/api.register.class.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $class_name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterDefaultPluginHandler
* Registers a default plugin handler
*
* @api Smarty::registerDefaultPluginHandler()
* @link https://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
* @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param callable $callback class/method name
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_RegisterFilter
*
* @api Smarty::registerFilter()
*
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterObject
* Registers object to be used in templates
*
* @api Smarty::registerObject()
* @link https://www.smarty.net/docs/en/api.register.object.tpl
* @link http://www.smarty.net/docs/en/api.register.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterPlugin
* Registers plugin to be used in templates
*
* @api Smarty::registerPlugin()
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type plugin type
@@ -48,8 +48,6 @@ 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);
}
@@ -22,18 +22,25 @@ class Smarty_Internal_Method_RegisterResource
* Registers a resource to fetch a template
*
* @api Smarty::registerResource()
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
* @link http://www.smarty.net/docs/en/api.register.resource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $name name of resource type
* @param Smarty_Resource $resource_handler instance of Smarty_Resource
* @param Smarty_Resource|array $resource_handler or instance of
* Smarty_Resource,
* or array of
* callbacks to
* handle
* resource
* (deprecated)
*
* @return \Smarty|\Smarty_Internal_Template
*/
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, Smarty_Resource $resource_handler)
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler)
{
$smarty = $obj->_getSmartyObj();
$smarty->registered_resources[ $name ] = $resource_handler;
$smarty->registered_resources[ $name ] =
$resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false);
return $obj;
}
}
@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
*
* @api Smarty::unloadFilter()
*
* @link https://www.smarty.net/docs/en/api.unload.filter.tpl
* @link http://www.smarty.net/docs/en/api.unload.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterCacheResource
* Registers a resource to fetch a template
*
* @api Smarty::unregisterCacheResource()
* @link https://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
* @link http://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param $name
@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_Reg
*
* @api Smarty::unregisterFilter()
*
* @link https://www.smarty.net/docs/en/api.unregister.filter.tpl
* @link http://www.smarty.net/docs/en/api.unregister.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterObject
* Registers plugin to be used in templates
*
* @api Smarty::unregisterObject()
* @link https://www.smarty.net/docs/en/api.unregister.object.tpl
* @link http://www.smarty.net/docs/en/api.unregister.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name name of object
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterPlugin
* Registers plugin to be used in templates
*
* @api Smarty::unregisterPlugin()
* @link https://www.smarty.net/docs/en/api.unregister.plugin.tpl
* @link http://www.smarty.net/docs/en/api.unregister.plugin.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type plugin type
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterResource
* Registers a resource to fetch a template
*
* @api Smarty::unregisterResource()
* @link https://www.smarty.net/docs/en/api.unregister.resource.tpl
* @link http://www.smarty.net/docs/en/api.unregister.resource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type name of resource type
@@ -85,85 +85,45 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
$code = '';
foreach ($this->getChunkedSubtrees() as $chunk) {
$text = '';
switch ($chunk['mode']) {
case 'textstripped':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
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;
}
$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;
$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);
}
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,31 +16,14 @@
*/
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
{
/**
* 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)
public function __construct($data)
{
$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;
}
/**
@@ -0,0 +1,101 @@
<?php
/**
* Smarty Internal Plugin Resource Registered
*
* @package Smarty
* @subpackage TemplateResources
* @author Uwe Tews
* @author Rodney Rehm
*/
/**
* Smarty Internal Plugin Resource Registered
* Implements the registered resource for Smarty template
*
* @package Smarty
* @subpackage TemplateResources
* @deprecated
*/
class Smarty_Internal_Resource_Registered extends Smarty_Resource
{
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*
* @return void
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
$source->filepath = $source->type . ':' . $source->name;
$source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir);
$source->timestamp = $this->getTemplateTimestamp($source);
$source->exists = !!$source->timestamp;
}
/**
* populate Source Object with timestamp and exists from Resource
*
* @param Smarty_Template_Source $source source object
*
* @return void
*/
public function populateTimestamp(Smarty_Template_Source $source)
{
$source->timestamp = $this->getTemplateTimestamp($source);
$source->exists = !!$source->timestamp;
}
/**
* Get timestamp (epoch) the template source was modified
*
* @param Smarty_Template_Source $source source object
*
* @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
*/
public function getTemplateTimestamp(Smarty_Template_Source $source)
{
// return timestamp
$time_stamp = false;
call_user_func_array(
$source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
array($source->name, &$time_stamp, $source->smarty)
);
return is_numeric($time_stamp) ? (int)$time_stamp : $time_stamp;
}
/**
* Load template's source by invoking the registered callback into current template object
*
* @param Smarty_Template_Source $source source object
*
* @return string template source
* @throws SmartyException if source cannot be loaded
*/
public function getContent(Smarty_Template_Source $source)
{
// return template string
$content = null;
$t = call_user_func_array(
$source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
array($source->name, &$content, $source->smarty)
);
if (is_bool($t) && !$t) {
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
}
return $content;
}
/**
* Determine basename for compiled filename
*
* @param Smarty_Template_Source $source source object
*
* @return string resource's basename
*/
public function getBasename(Smarty_Template_Source $source)
{
return basename($source->name);
}
}
@@ -13,7 +13,7 @@
* Smarty Internal Plugin Resource Stream
* Implements the streams as resource for Smarty template
*
* @link https://php.net/streams
* @link http://php.net/streams
* @package Smarty
* @subpackage TemplateResources
*/
@@ -138,7 +138,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* test if cache is valid
*
* @api Smarty::isCached()
* @link https://www.smarty.net/docs/en/api.is.cached.tpl
* @link http://www.smarty.net/docs/en/api.is.cached.tpl
*
* @param null|string|\Smarty_Internal_Template $template the resource handle of the template file or template
* object
@@ -199,12 +199,6 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
try {
$_smarty_old_error_level =
isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null;
if ($smarty->isMutingUndefinedOrNullWarnings()) {
$errorHandler = new Smarty_Internal_ErrorHandler();
$errorHandler->activate();
}
if ($this->_objType === 2) {
/* @var Smarty_Internal_Template $this */
$template->tplFunctions = $this->tplFunctions;
@@ -248,11 +242,6 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
}
}
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
@@ -261,10 +250,6 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
while (ob_get_level() > $level) {
ob_end_clean();
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
@@ -276,7 +261,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers plugin to be used in templates
*
* @api Smarty::registerPlugin()
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
*
* @param string $type plugin type
* @param string $name name of template tag
@@ -296,7 +281,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* load a filter of specified type and name
*
* @api Smarty::loadFilter()
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
*
* @param string $type filter type
* @param string $name filter name
@@ -313,7 +298,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers a filter function
*
* @api Smarty::registerFilter()
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
*
* @param string $type filter type
* @param callable $callback
@@ -331,7 +316,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers object to be used in templates
*
* @api Smarty::registerObject()
* @link https://www.smarty.net/docs/en/api.register.object.tpl
* @link http://www.smarty.net/docs/en/api.register.object.tpl
*
* @param string $object_name
* @param object $object the referenced PHP object to register
@@ -203,6 +203,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public $blockOrFunctionCode = '';
/**
* php_handling setting either from Smarty or security
*
* @var int
*/
public $php_handling = 0;
/**
* flags for used modifier plugins
*
@@ -431,6 +438,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
$this->smarty->_debug->start_compile($this->template);
}
if (isset($this->template->smarty->security_policy)) {
$this->php_handling = $this->template->smarty->security_policy->php_handling;
} else {
$this->php_handling = $this->template->smarty->php_handling;
}
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
$nocache = isset($nocache) ? $nocache : false;
if (empty($template->compiled->nocache_hash)) {
@@ -609,18 +621,22 @@ abstract class Smarty_Internal_TemplateCompilerBase
|| strcasecmp($name, 'array') === 0 || is_callable($name)
) {
$func_name = strtolower($name);
$par = implode(',', $parameter);
$parHasFuction = strpos($par, '(') !== false;
if ($func_name === 'isset') {
if (count($parameter) === 0) {
$this->trigger_template_error('Illegal number of parameter in "isset()"');
}
$pa = array();
foreach ($parameter as $p) {
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
if ($parHasFuction) {
$pa = array();
foreach ($parameter as $p) {
$pa[] = (strpos($p, '(') === false) ? ('isset(' . $p . ')') : ('(' . $p . ' !== null )');
}
return '(' . implode(' && ', $pa) . ')';
} else {
$isset_par = str_replace("')->value", "',null,true,false)->value", $par);
}
return '(' . implode(' && ', $pa) . ')';
return $name . '(' . $isset_par . ')';
} elseif (in_array(
$func_name,
array(
@@ -637,8 +653,12 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
}
if ($func_name === 'empty') {
return $func_name . '(' .
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
if ($parHasFuction && version_compare(PHP_VERSION, '5.5.0', '<')) {
return '(' . $parameter[ 0 ] . ' === false )';
} else {
return $func_name . '(' .
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
}
} else {
return $func_name . '(' . $parameter[ 0 ] . ')';
}
@@ -652,81 +672,73 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
/**
* Determines whether the passed string represents a valid (PHP) variable.
* This is important, because `isset()` only works on variables and `empty()` can only be passed
* a variable prior to php5.5
* @param $string
* @return bool
*/
private function syntaxMatchesVariable($string) {
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
return 1 === preg_match($regex_pattern, trim($string));
}
/**
* This method is called from parser to process a text content section if strip is enabled
* This method is called from parser to process a text content section
* - remove text from inheritance child templates as they may generate output
* - strip text if strip is enabled
*
* @param string $text
*
* @return string
* @return null|\Smarty_Internal_ParseTree_Text
*/
public function processText($text)
{
if (strpos($text, '<') === false) {
return preg_replace($this->stripRegEx, '', $text);
}
$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++;
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);
}
$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;
return null;
}
/**
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -362,6 +362,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_compile_function.php' => true,
'smarty_internal_compile_if.php' => true,
'smarty_internal_compile_include.php' => true,
'smarty_internal_compile_include_php.php' => true,
'smarty_internal_compile_insert.php' => true,
'smarty_internal_compile_ldelim.php' => true,
'smarty_internal_compile_make_nocache.php' => true,
@@ -372,6 +373,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_compile_private_modifier.php' => true,
'smarty_internal_compile_private_object_block_function.php' => true,
'smarty_internal_compile_private_object_function.php' => true,
'smarty_internal_compile_private_php.php' => true,
'smarty_internal_compile_private_print_expression.php' => true,
'smarty_internal_compile_private_registered_block.php' => true,
'smarty_internal_compile_private_registered_function.php' => true,
@@ -386,6 +388,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_config_file_compiler.php' => true,
'smarty_internal_data.php' => true,
'smarty_internal_debug.php' => true,
'smarty_internal_errorhandler.php' => true,
'smarty_internal_extension_handler.php' => true,
'smarty_internal_method_addautoloadfilters.php' => true,
'smarty_internal_method_adddefaultmodifiers.php' => true,
@@ -447,6 +450,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_resource_extends.php' => true,
'smarty_internal_resource_file.php' => true,
'smarty_internal_resource_php.php' => true,
'smarty_internal_resource_registered.php' => true,
'smarty_internal_resource_stream.php' => true,
'smarty_internal_resource_string.php' => true,
'smarty_internal_runtime_cachemodify.php' => true,

Some files were not shown because too many files have changed in this diff Show More