Skip to content

Commit 2c51320

Browse files
Merge pull request #5102 in SW/shopware from sw-18917/5.2/fix-string-compiler to 5.2
* commit '283bb52301af9fef4da9bc8d8cc4b6a1f27bc767': SW-18917 - Add whitelist for smarty functions SW-18917 - Optimize template security for mail preview and merchant mails
2 parents 710beec + 283bb52 commit 2c51320

File tree

6 files changed

+419
-1
lines changed

6 files changed

+419
-1
lines changed

engine/Shopware/Components/StringCompiler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public function compileSmartyString($value, $context)
164164

165165
try {
166166
$template = $templateEngine->createTemplate('string:' . $value);
167-
$template->enableSecurity();
168167
$template->assign($context);
169168
$template = $template->fetch();
170169
} catch (SmartyCompilerException $e) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Shopware 5
4+
* Copyright (c) shopware AG
5+
*
6+
* According to our dual licensing model, this program can be used either
7+
* under the terms of the GNU Affero General Public License, version 3,
8+
* or under a proprietary license.
9+
*
10+
* The texts of the GNU Affero General Public License with an additional
11+
* permission and of our proprietary license can be found at and
12+
* in the LICENSE file you have received along with this program.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* "Shopware" is a registered trademark of shopware AG.
20+
* The licensing of the program under the AGPLv3 does not imply a
21+
* trademark license. Therefore any rights, title and interest in
22+
* our trademarks remain entirely with us.
23+
*/
24+
25+
namespace Shopware\Components\Template;
26+
27+
class Security extends \Smarty_Security
28+
{
29+
public function __construct(\Smarty $smarty, $config = [])
30+
{
31+
if (is_array($config)) {
32+
foreach ($config as $key => $value) {
33+
if (property_exists($this, $key)) {
34+
$this->$key = $value;
35+
}
36+
}
37+
}
38+
39+
parent::__construct($smarty);
40+
}
41+
}

engine/Shopware/Configs/Default.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,8 @@
199199
'use_trans_sid' => 0,
200200
'locking' => false,
201201
],
202+
'template_security' => [
203+
'php_modifiers' => include __DIR__ . '/smarty_functions.php',
204+
'php_functions' => include __DIR__ . '/smarty_functions.php',
205+
],
202206
], $customConfig);

0 commit comments

Comments
 (0)