]> git.mxchange.org Git - friendica.git/commitdiff
template proc: fix variables regexp
authorFabio Comuni <fabrix.xm@gmail.com>
Fri, 2 Mar 2012 23:00:38 +0000 (00:00 +0100)
committerFabio Comuni <fabrix.xm@gmail.com>
Fri, 2 Mar 2012 23:00:38 +0000 (00:00 +0100)
include/template_processor.php

index 111fc5849a7b8af9041ffe465653722bfd3b464e..8671587fc4b48d57d60934cfd350c89aef2f00aa 100755 (executable)
 
                private function var_replace($s){
                        $m = array();
-                       if (preg_match_all('/\$\[{0,1}([a-zA-Z0-9-_]+\.*)+\]{0,1}/', $s,$m)){
+                       /** regexp:
+                        * \$                                           literal $
+                        * (\[)?                                        optional open square bracket
+                        * ([a-zA-Z0-9-_]+\.?)+         var name, followed by optional
+                        *                                                      dot, repeated at least 1 time
+                        * (?(1)\])                                     if there was opened square bracket
+                        *                                                      (subgrup 1), match close bracket
+                        */
+                       if (preg_match_all('/\$(\[)?([a-zA-Z0-9-_]+\.?)+(?(1)\])/', $s,$m)){
+                               
                                foreach($m[0] as $var){
                                        $varn = str_replace(array("[","]"), array("",""), $var);
                                        $val = $this->_get_var($varn, true);