Commit a1d321a8 by seldaek

Fixed a bug when accessing array indices that contain a minus sign, it is now…

Fixed a bug when accessing array indices that contain a minus sign, it is now possible to access those using {$var[index-foo]}, {$var['index-foo']} or {$index="index-foo"} {$var[$index]} fixes #44 git-svn-id: svn://dwoo.org/dwoo/trunk@286 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent a00e95bf
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
passed the compiler directly to the get method with autoEscape enabled, passed the compiler directly to the get method with autoEscape enabled,
the autoEscape was disabled in included templates - Thanks to Fabien the autoEscape was disabled in included templates - Thanks to Fabien
Potencier for notifying me. Potencier for notifying me.
* Fixed a bug when accessing array indices that contain a minus sign, it
is now possible to access those using {$var[index-foo]},
{$var['index-foo']} or {$index="index-foo"} {$var[$index]}
[2009-07-18] 1.1.0 [2009-07-18] 1.1.0
! BC Break: Dwoo::initGlobals() is only called once during the Dwoo object ! BC Break: Dwoo::initGlobals() is only called once during the Dwoo object
......
...@@ -1230,7 +1230,7 @@ class Dwoo ...@@ -1230,7 +1230,7 @@ class Dwoo
} }
if (is_array($varstr) === false) { if (is_array($varstr) === false) {
preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $varstr, $m); preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
} else { } else {
$m = $varstr; $m = $varstr;
} }
...@@ -1334,7 +1334,7 @@ class Dwoo ...@@ -1334,7 +1334,7 @@ class Dwoo
$varstr = 'dwoo'.$varstr; $varstr = 'dwoo'.$varstr;
} }
preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $varstr, $m); preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
} }
$i = $m[2][0]; $i = $m[2][0];
......
...@@ -2283,7 +2283,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler ...@@ -2283,7 +2283,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
} }
} }
} else { } else {
preg_match_all('#(\[|->|\.)?([a-z0-9_]+|(\\\?[\'"])[^\3]*?\3)\]?#i', $key, $m); preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+|(\\\?[\'"])[^\3]*?\3)\]?#i', $key, $m);
$i = $m[2][0]; $i = $m[2][0];
if ($i === '_parent' || $i === '_') { if ($i === '_parent' || $i === '_') {
...@@ -2337,7 +2337,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler ...@@ -2337,7 +2337,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
} }
} }
} else { } else {
preg_match_all('#(\[|->|\.)?([a-z0-9_]+)\]?#i', $key, $m); preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m);
unset($m[0]); unset($m[0]);
$output = '$this->readVar('.str_replace("\n", '', var_export($m, true)).')'; $output = '$this->readVar('.str_replace("\n", '', var_export($m, true)).')';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment