From 8caa4950730eebad56fd9faa94ee1a00e4a73f4e Mon Sep 17 00:00:00 2001 From: conory Date: Wed, 27 Jan 2016 19:03:16 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=80=EB=AC=B8=EC=9E=90=20=EC=83=81?= =?UTF-8?q?=EC=88=98=20=EC=9D=B8=EC=8B=9D,=20=ED=85=9C=ED=94=8C=EB=A6=BF?= =?UTF-8?q?=EC=97=90=EC=84=9C=20$=5FSERVER=20=EB=B3=80=EC=88=98=EB=A5=BC?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/template/TemplateHandler.class.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index dcdd16b1b..b42b5327e 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -250,7 +250,7 @@ class TemplateHandler $buff = $this->_parseInline($buff); // include, unload/load, import - $buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|(\s*)/', array($this, '_parseResource'), $buff); + $buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|[_A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|(\s*)/', array($this, '_parseResource'), $buff); // remove block which is a virtual tag $buff = preg_replace('@@is', '', $buff); @@ -598,6 +598,11 @@ class TemplateHandler return $m[0]; } + if(!preg_match('/[^_A-Z]+/', $m[1]) && !defined($m[1])) + { + return $m[0]; + } + if($m[1]{0} == '@') { $m[1] = self::_replaceVar(substr($m[1], 1)); @@ -863,7 +868,7 @@ class TemplateHandler /** * replace PHP variables of $ character * @param string $php - * @return string $__Context->varname + * @return string ex. $__Context->varname */ private static function _replaceVar($php) { @@ -871,7 +876,18 @@ class TemplateHandler { return ''; } - return preg_replace('@(?$1', $php); + + $callback = function($n) + { + if(preg_match('/^_(_Context|SERVER|COOKIE)/i', $n[1])) + { + return $n[0]; + } + + return '$__Context->' . $n[1]; + }; + + return preg_replace_callback('/\$([_a-z0-9^\s]+)/i', $callback, $php); } }