mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 04:24:18 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c0072430c | |||
| 07de9164b7 | |||
| 4698dd9fb0 | |||
| 039043e5a2 | |||
| 290aee6db3 | |||
| e2485fa45e | |||
| e27da524f7 | |||
| a21f59663c | |||
| 3148d406a0 | |||
| 4f634c0097 | |||
| c9272058d9 | |||
| e66e293a8a | |||
| 74cab5a56b | |||
| 8fc66e27a7 | |||
| 2543174460 | |||
| 288a54f6b0 | |||
| 165f1bd4d2 | |||
| 6463519a6c | |||
| fedc127057 | |||
| 3af2df20a4 |
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- modifier escape now triggers a E_USER_NOTICE when an unsupported escape type is used https://github.com/smarty-php/smarty/pull/649
|
||||
|
||||
### Fixed
|
||||
- Fixed render crash when using inline include with a string template https://github.com/smarty-php/smarty/issues/639
|
||||
|
||||
## [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
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.)
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| 3.1.x | :white_check_mark: |
|
||||
| < 3.1 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you have discovered a security issue with Smarty, please contact us at mail [at] simonwisselink.nl. Do not
|
||||
disclose your findings publicly and PLEASE PLEASE do not file an Issue.
|
||||
|
||||
We will try to confirm the vulnerability and develop a fix if appropriate. When we release the fix, we will publish
|
||||
a security release. Please let us know if you want to be credited.
|
||||
@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.38';
|
||||
const SMARTY_VERSION = '3.1.39';
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
|
||||
@@ -250,6 +250,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
}
|
||||
return $return;
|
||||
default:
|
||||
trigger_error("escape: unsupported type: $esc_type - returning unmodified string", E_USER_NOTICE);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)';
|
||||
|
||||
@@ -317,7 +317,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$tpl->template_resource = $template;
|
||||
$tpl->cache_id = $cache_id;
|
||||
$tpl->compile_id = $compile_id;
|
||||
if (isset($uid)) {
|
||||
if (isset($uid) && isset($tpl->compiled->file_dependency[ $uid ])) {
|
||||
// for inline templates we can get all resource information from file dependency
|
||||
list($filepath, $timestamp, $type) = $tpl->compiled->file_dependency[ $uid ];
|
||||
$tpl->source = new Smarty_Template_Source($smarty, $filepath, $type, $filepath);
|
||||
|
||||
+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'
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -324,4 +324,12 @@ class CompileIncludeTest extends PHPUnit_Smarty
|
||||
array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Inline Include with string template
|
||||
*/
|
||||
public function testInlineStringInclude()
|
||||
{
|
||||
$this->assertEquals('include-inline', $this->smarty->fetch('inline_string_include.tpl'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{include "string:include-inline" inline}
|
||||
@@ -210,6 +210,7 @@ class CompileInsertTest extends PHPUnit_Smarty
|
||||
* test insert plugin caching 2
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @group slow
|
||||
*/
|
||||
public function testInsertPluginCaching3_2()
|
||||
{
|
||||
|
||||
@@ -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}');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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