diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index a8985a771c..568727be82 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -373,33 +373,21 @@ class phpbb_template_filter extends php_user_filter
*/
private function parse_dynamic_path($path, $include_type)
{
- $segments = explode('/', $path);
- $is_expr = true;
- $str = array();
- $vars = array();
+ $matches = array();
+ $replace = array();
- foreach ($segments as $segment)
+ preg_match_all('/{[^}]+}/', $path, $matches);
+ foreach ($matches[0] as $var_str)
{
- if ($segment[0] === '{')
- {
- $var = $this->get_varref($segment, $tmp_is_expr);
- $is_expr = $is_expr && $tmp_is_expr;
- $vars[] = "isset($var)";
- $str[] = "$var . '/'";
- }
- else
- {
- $str[] = "'$segment/'";
- }
+ $var = $this->get_varref($var_str, $tmp_is_expr);
+ $is_expr = $is_expr && $tmp_is_expr;
+ $vars[] = "isset($var)";
+ $replace[] = "' . $var . '";
}
- // Remove trailing slash from last element
- $last = array_pop($str);
- $str[] = str_replace('/', '', $last);
-
if (!$is_expr)
{
- return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type(" . implode(' . ', $str) . ', true); }';
+ return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true); }";
}
else
{
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index d8c7170e94..22b020208b 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -23,10 +23,11 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
'',
'',
'',
+ '',
);
// Run test
$cache_file = $this->template->cachepath . 'includejs.html.php';
- $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir'), array(), array(), implode('', $scripts), $cache_file);
+ $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file);
}
}
diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html
index dbcf6e04a8..ef73700eeb 100644
--- a/tests/template/templates/includejs.html
+++ b/tests/template/templates/includejs.html
@@ -4,4 +4,5 @@
+
{SCRIPTS}