Skip to content

Commit

Permalink
Enabled Twig Sandbox MOde
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- committed Jan 6, 2024
1 parent 8c0516f commit 9077f70
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.1.2 (January 6, 2024)
----------------------
- Enh: Added Twig SecurityPolicy

1.1.1 (August 5, 2022)
----------------------
- Fix #15: Fixed HumHub 1.12+ support / Twig 3 Migration
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Virtual Card Popover",
"description": "Shows a virtual business card displaying brief information about the user when hovering over a user's profile picture or name",
"keywords": ["business card, popover, hover, profile information"],
"version": "1.1.1",
"version": "1.1.2",
"humhub": {
"minVersion": "1.12"
},
Expand Down
4 changes: 4 additions & 0 deletions widgets/VCardSpace.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Twig\Extension\SandboxExtension;
use Twig\Loader\ArrayLoader;
use Twig\Sandbox\SecurityPolicy;
use Yii;


Expand All @@ -42,6 +44,8 @@ public function run()
$memberCount = Membership::getSpaceMembersQuery($this->space)->count();

$twig = new Environment(new ArrayLoader());
$twig->addExtension(new SandboxExtension(new SecurityPolicy(['if', 'for'], ['escape']), true));

$templateParams = ['space' => $this->space, 'memberCount' => $memberCount];

try {
Expand Down
4 changes: 4 additions & 0 deletions widgets/VCardUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Twig\Extension\SandboxExtension;
use Twig\Loader\ArrayLoader;
use Twig\Sandbox\SecurityPolicy;
use Yii;


Expand All @@ -31,6 +33,8 @@ public function run()
$module = Yii::$app->getModule('popover-vcard');

$twig = new Environment(new ArrayLoader());
$twig->addExtension(new SandboxExtension(new SecurityPolicy(['if', 'for'], ['escape']), true));

$templateParams = ['user' => $this->user, 'profile' => $this->user->profile];

try {
Expand Down

0 comments on commit 9077f70

Please sign in to comment.