Skip to content

Commit 098822b

Browse files
committed
Merge branch 'release/4.0.4' into v4
2 parents 61df73c + c654ca7 commit 098822b

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+
## 4.0.4 - 2025.06.10
6+
### Fixed
7+
* Remove errant dependency on SEOmatic in the `SecurityPolicy` helper class
8+
59
## 4.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": "4.0.3",
4+
"version": "4.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: 80002 # PHP 8.0.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
@@ -62,7 +62,7 @@ public function checkMethodAllowed($obj, $method): void
6262
return;
6363
}
6464

65-
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
65+
$method = strtolower($method);
6666
$allowed = true;
6767
foreach ($this->getTwigMethods() as $class => $methods) {
6868
if ($obj instanceof $class) {
@@ -85,7 +85,7 @@ public function checkMethodAllowed($obj, $method): void
8585
public function checkPropertyAllowed($obj, $property): void
8686
{
8787
$allowed = true;
88-
$property = strtr($property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
88+
$property = strtolower($property);
8989
foreach ($this->getTwigProperties() as $class => $properties) {
9090
if ($obj instanceof $class) {
9191
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
@@ -62,7 +62,7 @@ public function checkMethodAllowed($obj, $method): void
6262
return;
6363
}
6464

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

0 commit comments

Comments
 (0)