From f14f2dcc6f9055f781d2c2581271ad1d41d9f354 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 4 May 2015 22:44:29 +0200 Subject: [PATCH] - bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22) --- change_log.txt | 3 +++ libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_resource.php | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index 09185b6fc..3fd9dd352 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.22-dev ===== (xx.xx.2015) + 04.05.2015 + - bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22) + 28.04.2015 - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2nd fix diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index f67c1861c..231a62b1f 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.22-dev/21'; + const SMARTY_VERSION = '3.1.22-dev/22'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_resource.php b/libs/sysplugins/smarty_resource.php index 53f59b208..b3c06cc7c 100644 --- a/libs/sysplugins/smarty_resource.php +++ b/libs/sysplugins/smarty_resource.php @@ -218,15 +218,15 @@ public static function load(Smarty $smarty, $type) */ public static function parseResourceName($resource_name, $default_resource) { - $parts = explode(':', $resource_name, 2); - if (!isset($parts[1]) || !isset($parts[0][1])) { + if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { + $type = $match[1]; + $name = substr($resource_name, strlen($match[0])); + } else { // no resource given, use default // or single character before the colon is not a resource type, but part of the filepath $type = $default_resource; $name = $resource_name; - } else { - $type = $parts[0]; - $name = $parts[1]; + } return array($name, $type); }