Skip to content

Commit

Permalink
OEL-337: Use minimal secure versions of twig.
Browse files Browse the repository at this point in the history
  • Loading branch information
yenyasinn committed Aug 16, 2021
1 parent 123dec4 commit 0cf5b8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"prefer-stable": true,
"require": {
"php": ">=7.2",
"twig/twig": "^1.34 || ^2.14"
"twig/twig": "^1.38 || ^2.7"
},
"require-dev": {
"cweagans/composer-patches": "~1.6",
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
cacheResult="false">
<testsuites>
<testsuite>
<testsuite name="ECL Twig Loader">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
10 changes: 8 additions & 2 deletions src/Loader/EuropaComponentLibraryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace OpenEuropa\Twig\Loader;

use Twig\Loader\FilesystemLoader;
use Twig\Error\LoaderError;

/**
* Class EuropaComponentLibraryLoader.
*
* @package OpenEuropa\Twig\Loader
*/
class EuropaComponentLibraryLoader extends \Twig\Loader\FilesystemLoader
class EuropaComponentLibraryLoader extends FilesystemLoader
{

/**
Expand Down Expand Up @@ -134,11 +137,14 @@ protected function isFullName($componentName)
return (bool) preg_match("/^{$this->prefix}(.*)\/{$this->templatePrefix}(.*){$this->extension}$/", $componentName);
}

/**
* Copy of private function Twig\Loader\FilesystemLoader::parseName().
*/
protected function parseName($name, $default = self::MAIN_NAMESPACE): array
{
if (isset($name[0]) && '@' === $name[0]) {
if (false === $pos = strpos($name, '/')) {
throw new \Twig\Error\LoaderError(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
throw new LoaderError(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
}

$namespace = substr($name, 1, $pos - 1);
Expand Down

0 comments on commit 0cf5b8f

Please sign in to comment.