mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 04:24:18 +02:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e05dabf369 | |||
| 1eb2851c03 | |||
| a832410ef3 | |||
| e27da524f7 | |||
| a21f59663c | |||
| 3148d406a0 | |||
| 4f634c0097 | |||
| c9272058d9 | |||
| e66e293a8a | |||
| 74cab5a56b | |||
| 8fc66e27a7 | |||
| 2543174460 | |||
| 288a54f6b0 | |||
| 165f1bd4d2 | |||
| 6463519a6c | |||
| fedc127057 | |||
| 3af2df20a4 | |||
| 63b3c0aed0 | |||
| 2af2a07906 | |||
| cb4254355e | |||
| f65e7ddd22 | |||
| 92e05d4f8d | |||
| e2b28167f8 | |||
| 820782cd80 | |||
| c295786e43 | |||
| 859a09e1bb | |||
| a5934a755d |
@@ -12,7 +12,6 @@
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/error_reporting.ini export-ignore
|
||||
/make-release.sh export-ignore
|
||||
/phpunit.sh export-ignore
|
||||
/phpunit.xml export-ignore
|
||||
|
||||
+14
-13
@@ -1,38 +1,39 @@
|
||||
language: php
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
sudo: false
|
||||
install:
|
||||
- travis_retry composer install
|
||||
|
||||
dist: trusty
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
include:
|
||||
- php: 5.3 # Composer requires PHP 5.3.2+ to run, so we cannot test below 5.3
|
||||
- php: 5.3 # Composer and PHPUnit require PHP 5.3.2+ to run, so we cannot test below 5.3
|
||||
dist: precise # PHP 5.3 is supported only on Precise.
|
||||
- php: 5.4
|
||||
dist: trusty # PHP 5.4 is supported only on Trusty.
|
||||
- php: 5.5
|
||||
dist: trusty # PHP 5.5 is supported only on Trusty.
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: 7.4
|
||||
# - php: nightly # PHP nightly build testing disabled because PHPUnit doesn't support PHP8 yet.
|
||||
- php: nightly
|
||||
install: travis_retry composer config platform.php 7.4.0 && composer install
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
- php: nightly # PHP 8 is still in beta
|
||||
|
||||
services:
|
||||
- memcached
|
||||
- mysql
|
||||
|
||||
before_script:
|
||||
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
||||
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini || return 0
|
||||
|
||||
install:
|
||||
- travis_retry composer install
|
||||
- phpenv config-rm xdebug.ini || return 0
|
||||
|
||||
script:
|
||||
- ./phpunit.sh
|
||||
- ./phpunit.sh
|
||||
|
||||
+20
-3
@@ -6,11 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- Travis unit tests now run for all php versions >= 5.3
|
||||
## [3.1.39] - 2021-02-17
|
||||
|
||||
### Security
|
||||
- Prevent access to `$smarty.template_object` in sandbox mode
|
||||
- Fixed code injection vulnerability by using illegal function names in `{function name='blah'}{/function}`
|
||||
|
||||
## [3.1.38] - 2021-01-08
|
||||
|
||||
### Fixed
|
||||
- PHP5.3 compatability fixes
|
||||
- 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
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Smarty: the PHP compiling template engine
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "6.4.1 || ^5.7 || ^4.8",
|
||||
"phpunit/phpunit": "^7.5 || ^6.5 || ^5.7 || ^4.8",
|
||||
"smarty/smarty-lexer": "^3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||
@@ -249,7 +249,13 @@ template ::= template PHP(B). {
|
||||
|
||||
// template text
|
||||
template ::= template TEXT(B). {
|
||||
$this->current_buffer->append_subtree($this, $this->compiler->processText(B));
|
||||
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
|
||||
if ((string)$text == '') {
|
||||
$this->current_buffer->append_subtree($this, null);
|
||||
}
|
||||
|
||||
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text($text, $this->strip));
|
||||
}
|
||||
// strip on
|
||||
template ::= template STRIPON. {
|
||||
@@ -308,7 +314,7 @@ smartytag(A)::= SIMPLETAG(B). {
|
||||
$tag = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
|
||||
if ($tag == 'strip') {
|
||||
$this->strip = true;
|
||||
A = null;;
|
||||
A = null;
|
||||
} else {
|
||||
if (defined($tag)) {
|
||||
if ($this->security) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -27,7 +27,6 @@
|
||||
* @author Uwe Tews <uwe dot tews at gmail dot com>
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
* @version 3.1.34-dev
|
||||
*/
|
||||
/**
|
||||
* set SMARTY_DIR to absolute path to Smarty library files.
|
||||
@@ -112,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.36';
|
||||
const SMARTY_VERSION = '3.1.39';
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
||||
@@ -58,6 +58,11 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
}
|
||||
unset($_attr[ 'nocache' ]);
|
||||
$_name = trim($_attr[ 'name' ], '\'"');
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9_\x80-\xff]+$/', $_name)) {
|
||||
$compiler->trigger_template_error("Function name contains invalid characters: {$_name}", null, true);
|
||||
}
|
||||
|
||||
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
||||
$save = array(
|
||||
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
||||
|
||||
@@ -81,6 +81,10 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
case 'template':
|
||||
return 'basename($_smarty_tpl->source->filepath)';
|
||||
case 'template_object':
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$compiler->trigger_template_error("(secure mode) template_object not permitted");
|
||||
break;
|
||||
}
|
||||
return '$_smarty_tpl';
|
||||
case 'current_dir':
|
||||
return 'dirname($_smarty_tpl->source->filepath)';
|
||||
@@ -94,9 +98,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
break;
|
||||
}
|
||||
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
||||
return "@constant('{$_index[1]}')";
|
||||
return "(defined('{$_index[1]}') ? constant('{$_index[1]}') : null)";
|
||||
} else {
|
||||
return "@constant({$_index[1]})";
|
||||
return "(defined({$_index[1]}) ? constant({$_index[1]}) : null)";
|
||||
}
|
||||
// no break
|
||||
case 'config':
|
||||
|
||||
@@ -115,7 +115,7 @@ class Smarty_Internal_Config_File_Compiler
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
// init the lexer/parser to compile the config file
|
||||
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
||||
/* @var Smarty_Internal_ConfigFileLexer $this->lex */
|
||||
$this->lex = new $this->lexer_class(
|
||||
str_replace(
|
||||
array(
|
||||
@@ -127,7 +127,7 @@ class Smarty_Internal_Config_File_Compiler
|
||||
) . "\n",
|
||||
$this
|
||||
);
|
||||
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
||||
/* @var Smarty_Internal_ConfigFileParser $this->parser */
|
||||
$this->parser = new $this->parser_class($this->lex, $this);
|
||||
if (function_exists('mb_internal_encoding')
|
||||
&& function_exists('ini_get')
|
||||
|
||||
@@ -65,7 +65,7 @@ class Smarty_Internal_ErrorHandler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
{
|
||||
$_is_muted_directory = false;
|
||||
// add the SMARTY_DIR to the list of muted directories
|
||||
|
||||
@@ -37,7 +37,8 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
$source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir :
|
||||
$source->smarty->_joined_template_dir)
|
||||
);
|
||||
$source->timestamp = filemtime($source->filepath);
|
||||
// When not doing compile_check, set timestamp to true
|
||||
$source->timestamp = $source->smarty->compile_check ? filemtime($source->filepath) : true;
|
||||
} else {
|
||||
$source->timestamp = $source->exists = false;
|
||||
}
|
||||
@@ -50,6 +51,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Source $source)
|
||||
{
|
||||
if (!$source->smarty->compile_check) {
|
||||
$source->timestamp = $source->exists = true;
|
||||
return;
|
||||
}
|
||||
if (!$source->exists) {
|
||||
$source->timestamp = $source->exists = is_file($source->filepath);
|
||||
}
|
||||
@@ -68,13 +73,15 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
*/
|
||||
public function getContent(Smarty_Template_Source $source)
|
||||
{
|
||||
if ($source->exists) {
|
||||
return file_get_contents($source->filepath);
|
||||
if (($source->smarty->compile_check && !$source->exists)
|
||||
|| false === ($content = file_get_contents($source->filepath))
|
||||
) {
|
||||
throw new SmartyException(
|
||||
'Unable to read ' . ($source->isConfig ? 'config' : 'template') .
|
||||
" {$source->type} '{$source->name}'"
|
||||
);
|
||||
}
|
||||
throw new SmartyException(
|
||||
'Unable to read ' . ($source->isConfig ? 'config' : 'template') .
|
||||
" {$source->type} '{$source->name}'"
|
||||
);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +133,17 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
$file = str_replace(DIRECTORY_SEPARATOR === '/' ? '\\' : '/', DIRECTORY_SEPARATOR, $file);
|
||||
}
|
||||
$_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
|
||||
|
||||
// If possible, assume the file exists when compile_check = false;
|
||||
if (!$source->smarty->compile_check
|
||||
&& count($_directories) == 1 // if there are multiple directories, we'll have to scan them
|
||||
&& $file[ 0 ] !== '[' // template_dir index
|
||||
&& !$source->smarty->use_include_path // cannot optimize when we need to use include path
|
||||
) {
|
||||
$path = reset($_directories) . $file;
|
||||
return (strpos($path, '.' . DIRECTORY_SEPARATOR) !== false) ? $source->smarty->_realpath($path) : $path;
|
||||
}
|
||||
|
||||
// template_dir index?
|
||||
if ($file[ 0 ] === '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) {
|
||||
$file = $fileMatch[ 2 ];
|
||||
@@ -157,6 +175,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
$_directories = $_index_dirs;
|
||||
}
|
||||
}
|
||||
|
||||
// relative file name?
|
||||
foreach ($_directories as $_directory) {
|
||||
$path = $_directory . $file;
|
||||
|
||||
@@ -74,9 +74,14 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
$this->filepath .= '.cache';
|
||||
}
|
||||
$this->filepath .= '.php';
|
||||
$this->timestamp = $this->exists = is_file($this->filepath);
|
||||
if ($this->exists) {
|
||||
$this->timestamp = filemtime($this->filepath);
|
||||
|
||||
if ($smarty->compile_check) {
|
||||
$this->timestamp = $this->exists = is_file($this->filepath);
|
||||
if ($this->exists) {
|
||||
$this->timestamp = filemtime($this->filepath);
|
||||
}
|
||||
} else {
|
||||
$this->timestamp = $this->exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +140,9 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
if ($source->handler->recompiled) {
|
||||
$source->handler->process($_smarty_tpl);
|
||||
} elseif (!$source->handler->uncompiled) {
|
||||
if (!$this->exists || $smarty->force_compile
|
||||
|| ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp())
|
||||
if (
|
||||
$smarty->force_compile ||
|
||||
($_smarty_tpl->compile_check && (!$this->exists || ($source->getTimeStamp() > $this->getTimeStamp())))
|
||||
) {
|
||||
$this->compileTemplateSource($_smarty_tpl);
|
||||
$compileCheck = $_smarty_tpl->compile_check;
|
||||
|
||||
+1
-1
@@ -14,6 +14,6 @@ git pull
|
||||
git merge --no-ff "release/$1"
|
||||
git branch -d "release/$1"
|
||||
git tag -a "v$1" -m "Release $1"
|
||||
git push --follow-tags
|
||||
|
||||
printf 'Done creating release %s\n' "$1"
|
||||
printf 'Run `git push --follow-tags origin` to publish it.\n'
|
||||
|
||||
@@ -16,7 +16,6 @@ if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Frame
|
||||
class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error_Error');
|
||||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning');
|
||||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Deprecated');
|
||||
class_alias('\PHPUnit\Util\Configuration', '\PHPUnit_Util_Configuration');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit_Smarty.php';
|
||||
|
||||
@@ -24,34 +24,37 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
|
||||
$this->cleanDirs();
|
||||
}
|
||||
/**
|
||||
* Test E_NOTICE suppression template fetched by Smarty object
|
||||
* Test Error suppression template fetched by Smarty object
|
||||
*/
|
||||
public function testE_NoticeDisabled()
|
||||
public function testErrorDisabled()
|
||||
{
|
||||
$e1 = error_reporting();
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
|
||||
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
|
||||
$e2 = error_reporting();
|
||||
$this->assertEquals($e1, $e2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test E_NOTICE suppression template fetched by template object
|
||||
* Test Error suppression template fetched by template object
|
||||
*/
|
||||
public function testE_NoticeDisabledTplObject_1()
|
||||
public function testErrorDisabledTplObject_1()
|
||||
{
|
||||
$e1 = error_reporting();
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
|
||||
$tpl = $this->smarty->createTemplate('001_main.tpl');
|
||||
$this->assertEquals('undefined = ', $tpl->fetch());
|
||||
$e2 = error_reporting();
|
||||
$this->assertEquals($e1, $e2);
|
||||
}
|
||||
|
||||
public function testE_NoticeDisabledTplObject_2()
|
||||
/**
|
||||
* Test Error suppression template object fetched by Smarty object
|
||||
*/
|
||||
public function testErrorDisabledTplObject_2()
|
||||
{
|
||||
$e1 = error_reporting();
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_NOTICE);
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
|
||||
$tpl = $this->smarty->createTemplate('001_main.tpl');
|
||||
$this->assertEquals('undefined = ', $this->smarty->fetch($tpl));
|
||||
$e2 = error_reporting();
|
||||
@@ -59,16 +62,31 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw E_NOTICE message
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
* @expectedExceptionMessage Undefined index: foo
|
||||
* Throw Error message
|
||||
*/
|
||||
public function testE_Notice()
|
||||
public function testError()
|
||||
{
|
||||
$e1 = error_reporting();
|
||||
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
|
||||
$e2 = error_reporting();
|
||||
$this->assertEquals($e1, $e2);
|
||||
$exceptionThrown = false;
|
||||
|
||||
try {
|
||||
$e1 = error_reporting();
|
||||
$this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl'));
|
||||
$e2 = error_reporting();
|
||||
$this->assertEquals($e1, $e2);
|
||||
} catch (Exception $e) {
|
||||
|
||||
$exceptionThrown = true;
|
||||
$this->assertStringStartsWith('Undefined ', $e->getMessage());
|
||||
$this->assertTrue(in_array(
|
||||
get_class($e),
|
||||
array(
|
||||
'PHPUnit_Framework_Error_Warning',
|
||||
'PHPUnit_Framework_Error_Notice',
|
||||
'PHPUnit\Framework\Error\Warning',
|
||||
'PHPUnit\Framework\Error\Notice',
|
||||
)
|
||||
));
|
||||
}
|
||||
$this->assertTrue($exceptionThrown);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class MuteExpectedErrorsTest extends PHPUnit_Smarty
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
{
|
||||
$this->_errors[] = $errfile . ' line ' . $errline;
|
||||
}
|
||||
|
||||
@@ -339,6 +339,10 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
||||
$this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
|
||||
$this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group slow
|
||||
*/
|
||||
public function testClearCacheExpired()
|
||||
{
|
||||
$this->smarty->caching = true;
|
||||
@@ -399,7 +403,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider data
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName)
|
||||
{
|
||||
|
||||
@@ -403,7 +403,11 @@ class ConfigVarTest extends PHPUnit_Smarty
|
||||
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->assertEquals('Undefined variable: foo', $e->getMessage());
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||
} else {
|
||||
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
||||
* test grandchild/child/parent dependency test2
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_2()
|
||||
{
|
||||
@@ -193,7 +193,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
||||
* test grandchild/child/parent dependency test4
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_4()
|
||||
{
|
||||
|
||||
@@ -382,6 +382,15 @@ class SecurityTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy->trusted_uri = array();
|
||||
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* In security mode, accessing $smarty.template_object should be illegal.
|
||||
* @expectedException SmartyCompilerException
|
||||
*/
|
||||
public function testSmartyTemplateObject() {
|
||||
$this->smarty->display('string:{$smarty.template_object}');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class mysecuritystaticclass
|
||||
|
||||
@@ -33,7 +33,7 @@ class ClearAllAssignBCTest extends PHPUnit_Smarty
|
||||
|
||||
public function testSmarty2ClearAllAssignInSmarty()
|
||||
{
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_WARNING | E_USER_NOTICE)));
|
||||
$this->smartyBC->clear_all_assign();
|
||||
$this->assertEquals('barblar', $this->smartyBC->fetch($this->_tplBC));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testClearAllAssignInTemplate()
|
||||
{
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
|
||||
$this->_tpl->clearAllAssign();
|
||||
$this->assertEquals('foobar', $this->smarty->fetch($this->_tpl));
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testClearAllAssignInData()
|
||||
{
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
|
||||
$this->_data->clearAllAssign();
|
||||
$this->assertEquals('fooblar', $this->smarty->fetch($this->_tpl));
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testClearAllAssignInSmarty()
|
||||
{
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
|
||||
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING)));
|
||||
$this->smarty->clearAllAssign();
|
||||
$this->assertEquals('barblar', $this->smarty->fetch($this->_tpl));
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ class ClearAssignBCTest extends PHPUnit_Smarty
|
||||
}
|
||||
public function testSmarty2ClearAssign()
|
||||
{
|
||||
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
|
||||
$this->smartyBC->clear_assign('blar');
|
||||
$this->assertEquals('foobar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}'));
|
||||
}
|
||||
|
||||
public function testSmarty2ArrayClearAssign()
|
||||
{
|
||||
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||
$this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
|
||||
$this->smartyBC->clear_assign(array('blar', 'foo'));
|
||||
$this->assertEquals('bar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}'));
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ClearAssignTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testClearAssign()
|
||||
{
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
|
||||
$this->smarty->clearAssign('blar');
|
||||
$this->assertEquals('foobar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}'));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class ClearAssignTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testArrayClearAssign()
|
||||
{
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
|
||||
$this->smarty->clearAssign(array('blar', 'foo'));
|
||||
$this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}'));
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_2()
|
||||
{
|
||||
@@ -645,7 +645,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_3()
|
||||
{
|
||||
@@ -670,7 +670,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_32()
|
||||
{
|
||||
@@ -692,6 +692,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_4()
|
||||
{
|
||||
@@ -716,6 +717,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @group slow
|
||||
*/
|
||||
public function testCompileBlockGrandChildMustCompile_021_42()
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ class CompileForeachTest extends PHPUnit_Smarty
|
||||
$this->smarty->assign('foo', $foo);
|
||||
} else {
|
||||
// unassigned $from parameter
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE | E_WARNING));
|
||||
}
|
||||
|
||||
$this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}");
|
||||
|
||||
@@ -210,6 +210,7 @@ class CompileInsertTest extends PHPUnit_Smarty
|
||||
* test insert plugin caching 2
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @group slow
|
||||
*/
|
||||
public function testInsertPluginCaching3_2()
|
||||
{
|
||||
|
||||
+1
-1
@@ -275,7 +275,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
||||
|
||||
protected $_errors = array();
|
||||
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
{
|
||||
$this->_errors[] = $errstr;
|
||||
}
|
||||
|
||||
+1
-1
@@ -369,7 +369,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
||||
|
||||
protected $_errors = array();
|
||||
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
{
|
||||
$this->_errors[] = $errstr;
|
||||
}
|
||||
|
||||
+1
-1
@@ -275,7 +275,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
||||
|
||||
protected $_errors = array();
|
||||
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
{
|
||||
$this->_errors[] = $errstr;
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ class CompileFunctionTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testExternalDefinedFunctionRecursion($text)
|
||||
{
|
||||
$this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text);
|
||||
$this->assertEquals('012345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,5 +431,14 @@ class CompileFunctionTest extends PHPUnit_Smarty
|
||||
array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++),
|
||||
array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test handling of function names that are a security risk
|
||||
* @expectedException SmartyCompilerException
|
||||
*/
|
||||
public function testIllegalFunctionName() {
|
||||
$this->smarty->fetch('string:{function name=\'rce(){};echo "hi";function \'}{/function}');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,11 +78,13 @@ class ConstantsTest extends PHPUnit_Smarty
|
||||
}
|
||||
public function testConstantsUndefined()
|
||||
{
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
|
||||
$tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}');
|
||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
||||
}
|
||||
public function testConstantsUndefined2()
|
||||
{
|
||||
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
|
||||
$tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}');
|
||||
$this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class SmartyNowTest extends PHPUnit_Smarty
|
||||
}
|
||||
/**
|
||||
* test {$smarty.now nocache}
|
||||
*
|
||||
* @group slow
|
||||
*/
|
||||
public function testSmartyNowNocache() {
|
||||
$this->smarty->setCaching(true);
|
||||
|
||||
@@ -59,7 +59,7 @@ class StreamVariableTest extends PHPUnit_Smarty
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* test no existant stream variable
|
||||
* test no existent stream variable
|
||||
*/
|
||||
// public function testStreamVariable2()
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user