Skip to content

Commit 9237604

Browse files
committed
Merge branch 'release/5.0.4' into v5
2 parents b606a44 + dbeccd0 commit 9237604

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 5.0.4 - 2025.06.10
6+
### Fixed
7+
* Remove errant dependency on SEOmatic in the `SecurityPolicy` helper class
8+
59
## 5.0.3 - 2025.06.08
610
### Added
711
* Add an example `config/blacklist-sandbox.php` and `config/whitelist-sandbox.php` files for user-customizable Twig sandbox environments

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nystudio107/craft-twig-sandbox",
33
"description": "Allows you to easily create a sandboxed Twig environment where you can control what tags, filters, functions, and object methods/properties are allowed",
4-
"version": "5.0.3",
4+
"version": "5.0.4",
55
"keywords": [
66
"craft",
77
"cms",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ includes:
33

44
parameters:
55
level: 5
6+
phpVersion: 80200 # PHP 8.2
67
paths:
78
- src

src/helpers/SecurityPolicy.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
use Craft;
66
use craft\helpers\ArrayHelper;
7-
use craft\helpers\StringHelper;
87
use nystudio107\crafttwigsandbox\twig\BaseSecurityPolicy;
9-
use nystudio107\seomatic\Seomatic;
108
use function is_array;
119

1210
class SecurityPolicy
@@ -57,7 +55,7 @@ public static function getConfigFromFile(string $filePath, ?string $alias = null
5755
$mergedConfig = [];
5856
/** @var array $config */
5957
foreach ($config as $env => $envConfig) {
60-
if ($env === '*' || StringHelper::contains(Seomatic::$environment, $env)) {
58+
if ($env === '*') {
6159
$mergedConfig = ArrayHelper::merge($mergedConfig, $envConfig);
6260
}
6361
}

src/twig/BlacklistSecurityPolicy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function checkMethodAllowed($obj, $method): void
6161
return;
6262
}
6363

64-
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
64+
$method = strtolower($method);
6565
$allowed = true;
6666
foreach ($this->getTwigMethods() as $class => $methods) {
6767
if ($obj instanceof $class) {
@@ -84,7 +84,7 @@ public function checkMethodAllowed($obj, $method): void
8484
public function checkPropertyAllowed($obj, $property): void
8585
{
8686
$allowed = true;
87-
$property = strtr($property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
87+
$property = strtolower($property);
8888
foreach ($this->getTwigProperties() as $class => $properties) {
8989
if ($obj instanceof $class) {
9090
if ($properties[0] === '*' || in_array($property, $properties, true)) {

src/twig/WhitelistSecurityPolicy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function checkMethodAllowed($obj, $method): void
6161
return;
6262
}
6363

64-
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
64+
$method = strtolower($method);
6565
$allowed = false;
6666
foreach ($this->getTwigMethods() as $class => $methods) {
6767
if ($obj instanceof $class) {
@@ -84,7 +84,7 @@ public function checkMethodAllowed($obj, $method): void
8484
public function checkPropertyAllowed($obj, $property): void
8585
{
8686
$allowed = false;
87-
$property = strtr($property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
87+
$property = strtolower($property);
8888
foreach ($this->getTwigProperties() as $class => $properties) {
8989
if ($obj instanceof $class) {
9090
if ($properties[0] === '*' || in_array($property, $properties, true)) {

0 commit comments

Comments
 (0)