Skip to content

Commit f0b09ec

Browse files
committed
2.14.0
1 parent 33102bc commit f0b09ec

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release Notes for Sprig
22

3+
## 2.14.0 - 2025-04-09
4+
5+
- Updated htmx to version 2.0.4 ([changelog](https://github.com/bigskysoftware/htmx/blob/master/CHANGELOG.md#204---2024-12-13)).
6+
- The Sprig Playground component template is now rendered in a sandboxed context.
7+
- Fixed an information disclosure vulnerability.
8+
- Fixed an XSS vulnerability.
9+
310
## 2.13.1 - 2024-10-23
411

512
### Changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "putyourlightson/craft-sprig",
33
"description": "A reactive Twig component framework for Craft.",
4-
"version": "2.13.1",
4+
"version": "2.14.0",
55
"type": "craft-plugin",
66
"license": "mit",
77
"require": {
88
"php": "^8.0.2",
99
"craftcms/cms": "^4.0",
1010
"nystudio107/craft-code-editor": "^1.0.0",
11-
"putyourlightson/craft-sprig-core": "^2.12.4"
11+
"nystudio107/craft-twig-sandbox": "^4.0.2",
12+
"putyourlightson/craft-sprig-core": "^2.13.0"
1213
},
1314
"require-dev": {
1415
"craftcms/ecs": "dev-main",

src/components/SprigPlayground.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Craft;
66
use craft\web\View;
77
use Exception;
8+
use nystudio107\crafttwigsandbox\web\SandboxView;
89
use putyourlightson\sprig\base\Component;
910
use putyourlightson\sprig\plugin\Sprig;
1011
use yii\web\ForbiddenHttpException;
@@ -41,7 +42,8 @@ public function render(): string
4142
Craft::$app->getResponse()->getHeaders()->set('Sprig-Playground-Variables', $headerVariables);
4243

4344
try {
44-
return Craft::$app->getView()->renderString($this->_getComponent(), $variables, View::TEMPLATE_MODE_SITE, true);
45+
$sandboxView = new SandboxView();
46+
return $sandboxView->renderString($this->_getComponent(), $variables, View::TEMPLATE_MODE_SITE, true);
4547
} catch (Exception $exception) {
4648
return $this->_getErrorMessage($exception->getMessage());
4749
}

src/controllers/PlaygroundController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function actionIndex(int $id = null, string $slug = null): Response
4646
*/
4747
public function actionSave(): Response
4848
{
49-
$request = Craft::$app->getRequest();
49+
$this->requirePostRequest();
5050

51-
$name = $request->getParam('name', '');
52-
$component = $request->getParam('component', '');
53-
$variables = $request->getParam('variables', '');
51+
$name = $this->request->getParam('name', '');
52+
$component = $this->request->getParam('component', '');
53+
$variables = $this->request->getParam('variables', '');
5454

5555
$id = Sprig::$plugin->playground->save($name, $component, $variables);
5656

@@ -64,11 +64,11 @@ public function actionSave(): Response
6464
*/
6565
public function actionUpdate(): Response
6666
{
67-
$request = Craft::$app->getRequest();
67+
$this->requirePostRequest();
6868

69-
$id = $request->getParam('id');
70-
$component = $request->getParam('component', '');
71-
$variables = $request->getParam('variables', '');
69+
$id = $this->request->getParam('id');
70+
$component = $this->request->getParam('component', '');
71+
$variables = $this->request->getParam('variables', '');
7272

7373
Sprig::$plugin->playground->update($id, $component, $variables);
7474

@@ -82,9 +82,9 @@ public function actionUpdate(): Response
8282
*/
8383
public function actionDelete(): Response
8484
{
85-
$request = Craft::$app->getRequest();
85+
$this->requirePostRequest();
8686

87-
$id = $request->getParam('id');
87+
$id = $this->request->getParam('id');
8888

8989
Sprig::$plugin->playground->delete($id);
9090

0 commit comments

Comments
 (0)