Skip to content

Commit

Permalink
Fix for formToken to not need raw filter
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevanzuydam committed Jun 22, 2024
1 parent 1e2722f commit eafe096
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ test.db
/src/public/images/test/
/log/deploy.log
/bin/tina4
/src/templates/index.twig
2 changes: 1 addition & 1 deletion Tina4/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Api

/**
* API constructor.
* @param ?string $baseURL
* @param string|null $baseURL
* @param string $authHeader Example - Authorization: Bearer AFD-22323-FD
* @tests tina4
* assert ("https://the-one-api.dev/v2", "Authorization: Bearer 123456") === null,"Could not initialize API"
Expand Down
4 changes: 2 additions & 2 deletions Tina4/Twig/TwigUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function initTwig(?Config $config = null): Environment
$twigPaths = ["cache", "src" . DIRECTORY_SEPARATOR . "templates", "src" . DIRECTORY_SEPARATOR . "public", "src" . DIRECTORY_SEPARATOR . "assets", "src" . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "snippets"];
}

Debug::message("TINA4: Twig Paths - " . str_replace("\n", "", print_r($twigPaths, 1)), TINA4_LOG_DEBUG);
Debug::message("TINA: Twig Paths - " . str_replace("\n", "", print_r($twigPaths, 1)), TINA4_LOG_DEBUG);

foreach ($twigPaths as $tid => $twigPath) {
if (!is_array($twigPath) && !file_exists($twigPath) && !file_exists(str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, TINA4_DOCUMENT_ROOT . $twigPath))) {
Expand Down Expand Up @@ -139,7 +139,7 @@ public static function initTwig(?Config $config = null): Environment

$filter = new TwigFilter("formToken", static function ($payload) use ($auth) {
if (!empty($_SERVER) && isset($_SERVER["REMOTE_ADDR"])) {
return _input(["type" => "hidden", "name" => "formToken", "value" => $auth->getToken(["formName" => $payload])]) . "";
return new \Twig\Markup(_input(["type" => "hidden", "name" => "formToken", "value" => $auth->getToken(["formName" => $payload])]) . "", "UTF-8");
}

return "";
Expand Down

0 comments on commit eafe096

Please sign in to comment.