add @ and === to if tokens, few param cleanups

This commit is contained in:
mohrt
2003-02-17 14:47:21 +00:00
parent f28f4da51e
commit b04bbd47c6
5 changed files with 19 additions and 8 deletions

5
NEWS
View File

@@ -1,3 +1,8 @@
- clean up param calls to _parse_var and _parse_attrs (Monte)
- define $template_source var, elude possible warning
(Monte)
- fix syntax problem with evaluating PHP constants (Monte)
- add @ and === as valid if statement tokens (Monte)
- enable error messages for config_load errors, - enable error messages for config_load errors,
use $this->config_class for loading class name (Monte) use $this->config_class for loading class name (Monte)
- fix html_options to not escape already escaped entities (Monte) - fix html_options to not escape already escaped entities (Monte)

View File

@@ -1418,6 +1418,7 @@ class Smarty
} }
} else if ($resource_type != 'file') { } else if ($resource_type != 'file') {
$readable = true; $readable = true;
$template_source = null;
$resource_func = $this->_plugins['resource'][$resource_type][0][0]; $resource_func = $this->_plugins['resource'][$resource_type][0][0];
$readable = $resource_func($resource_name, $template_source, $this); $readable = $resource_func($resource_name, $template_source, $this);
} }

View File

@@ -1086,7 +1086,7 @@ class Smarty_Compiler extends Smarty {
preg_match_all('/(?> preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string
\-?\d+(?:\.\d+)?|\.\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\* | # valid non-word token \-?\d+(?:\.\d+)?|\.\d+|!==|<=>|===|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
\b\w+\b | # valid word token \b\w+\b | # valid word token
\S+ # anything else \S+ # anything else
)/x', $tag_args, $match); )/x', $tag_args, $match);
@@ -1110,6 +1110,7 @@ class Smarty_Compiler extends Smarty {
case '%': case '%':
case '!==': case '!==':
case '==': case '==':
case '===':
case '>': case '>':
case '<': case '<':
case '!=': case '!=':
@@ -1127,6 +1128,7 @@ class Smarty_Compiler extends Smarty {
case '-': case '-':
case '*': case '*':
case '/': case '/':
case '@':
break; break;
case 'eq': case 'eq':
@@ -1346,7 +1348,7 @@ class Smarty_Compiler extends Smarty {
$token = true; $token = true;
} else if (preg_match('!^(off|no|false)$!', $token)) { } else if (preg_match('!^(off|no|false)$!', $token)) {
$token = false; $token = false;
} else if (preg_match('!^[\w\.-]+$!', $token)) { } else if ($quote && preg_match('!^[\w\.-]+$!', $token)) {
/* If the token is just a string, /* If the token is just a string,
we double-quote it. */ we double-quote it. */
$token = '"'.$token.'"'; $token = '"'.$token.'"';
@@ -1403,7 +1405,7 @@ class Smarty_Compiler extends Smarty {
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) { if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) {
// $ variable or object // $ variable or object
return $this->_parse_var($val, $tag_attrs); return $this->_parse_var($val);
} }
elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
// double quoted text // double quoted text
@@ -1778,7 +1780,7 @@ class Smarty_Compiler extends Smarty {
case 'const': case 'const':
array_shift($indexes); array_shift($indexes);
$compiled_ref = 'defined(\'' . substr($indexes[0],1) . '\') ? ' . substr($indexes[0],1) . ' : null'; $compiled_ref = '(defined(\'' . substr($indexes[0],1) . '\') ? ' . substr($indexes[0],1) . ' : null)';
break; break;
default: default:

View File

@@ -1418,6 +1418,7 @@ class Smarty
} }
} else if ($resource_type != 'file') { } else if ($resource_type != 'file') {
$readable = true; $readable = true;
$template_source = null;
$resource_func = $this->_plugins['resource'][$resource_type][0][0]; $resource_func = $this->_plugins['resource'][$resource_type][0][0];
$readable = $resource_func($resource_name, $template_source, $this); $readable = $resource_func($resource_name, $template_source, $this);
} }

View File

@@ -1086,7 +1086,7 @@ class Smarty_Compiler extends Smarty {
preg_match_all('/(?> preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string
\-?\d+(?:\.\d+)?|\.\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\* | # valid non-word token \-?\d+(?:\.\d+)?|\.\d+|!==|<=>|===|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
\b\w+\b | # valid word token \b\w+\b | # valid word token
\S+ # anything else \S+ # anything else
)/x', $tag_args, $match); )/x', $tag_args, $match);
@@ -1110,6 +1110,7 @@ class Smarty_Compiler extends Smarty {
case '%': case '%':
case '!==': case '!==':
case '==': case '==':
case '===':
case '>': case '>':
case '<': case '<':
case '!=': case '!=':
@@ -1127,6 +1128,7 @@ class Smarty_Compiler extends Smarty {
case '-': case '-':
case '*': case '*':
case '/': case '/':
case '@':
break; break;
case 'eq': case 'eq':
@@ -1346,7 +1348,7 @@ class Smarty_Compiler extends Smarty {
$token = true; $token = true;
} else if (preg_match('!^(off|no|false)$!', $token)) { } else if (preg_match('!^(off|no|false)$!', $token)) {
$token = false; $token = false;
} else if (preg_match('!^[\w\.-]+$!', $token)) { } else if ($quote && preg_match('!^[\w\.-]+$!', $token)) {
/* If the token is just a string, /* If the token is just a string,
we double-quote it. */ we double-quote it. */
$token = '"'.$token.'"'; $token = '"'.$token.'"';
@@ -1403,7 +1405,7 @@ class Smarty_Compiler extends Smarty {
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) { if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(?:' . $this->_mod_regexp . '*)$!', $val)) {
// $ variable or object // $ variable or object
return $this->_parse_var($val, $tag_attrs); return $this->_parse_var($val);
} }
elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { elseif(preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
// double quoted text // double quoted text
@@ -1778,7 +1780,7 @@ class Smarty_Compiler extends Smarty {
case 'const': case 'const':
array_shift($indexes); array_shift($indexes);
$compiled_ref = 'defined(\'' . substr($indexes[0],1) . '\') ? ' . substr($indexes[0],1) . ' : null'; $compiled_ref = '(defined(\'' . substr($indexes[0],1) . '\') ? ' . substr($indexes[0],1) . ' : null)';
break; break;
default: default: