Index: branches/RC/core/kernel/nparser/nparser.php
===================================================================
diff -u -r8929 -r8953
--- branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 8929)
+++ branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 8953)
@@ -52,7 +52,9 @@
// appending any text/html data found before tag
$this->Buffers[$this->Level] .= $tag_data[1][0];
if (!$this->InsideComment) {
- $this->ProcessTag($tag);
+ if ($this->ProcessTag($tag) === false) {
+ return false;
+ }
}
else {
$this->Buffers[$this->Level] .= $tag_data[2][0].$tag_data[3][0].$tag_data[4][0];
@@ -61,6 +63,7 @@
if ($this->Level > 0) {
$this->Application->handleError(E_USER_ERROR, 'Unclosed tag opened by '.$this->TagInfo($this->Stack[$this->Level]->Tag), $this->Stack[$this->Level]->Tag['file'], $this->Stack[$this->Level]->Tag['line']);
+ return false;
}
// appending text data after last tag (after its closing pos),
@@ -73,6 +76,7 @@
trigger_error('Saving compiled template failed', E_USER_ERROR);
}
fclose($compiled);
+ return true;
}
function SplitParamsStr($params_str)
@@ -93,6 +97,7 @@
if (!preg_match('/([^_ \t\n]*)[_]?([^ \t\n]*)[ \t\n]*(.*)$$/s', $tag['tag'], $parts)) {
// this is virtually impossible, but just in case
$this->Application->handleError(E_USER_ERROR, 'Incorrect tag format: '.$tag['tag'], $tag['file'], $tag['line']);
+ return false;
}
$splited['prefix'] = $parts[2] ? $parts[1] : '__auto__';
@@ -103,7 +108,9 @@
function ProcessTag($tag)
{
- $tag = array_merge($tag, $this->SplitTag($tag));
+ $splited = $this->SplitTag($tag);
+ if ($splited === false) return false;
+ $tag = array_merge($tag, $splited);
$tag['processed'] = false;
$tag['NP'] = $this->SplitParamsStr($tag['attrs']);
@@ -117,7 +124,9 @@
/* @var $instance _BlockTag */
$this->Stack[++$this->Level] =& $instance;
$this->Buffers[$this->Level] = '';
- $o .= $instance->Open($tag);
+ $open_code = $instance->Open($tag);
+ if ($open_code === false) return false;
+ $o .= $open_code;
}
if ($tag['is_closing']) { // not ELSE here, because tag may be and still has a handler-class
@@ -127,14 +136,16 @@
$dump[] = $instance->Tag;
}
print_pre($dump);
- $this->Application->handleError(E_USER_ERROR, 'Closing tag without an opening: '.$this->TagInfo($tag).' - probably opening tag was removed or nested tags error', $tag['file'], $tag['line']);
+ $this->Application->handleError(E_USER_ERROR, 'Closing tag without an opening: '.$this->TagInfo($tag).' - probably opening tag was removed or nested tags error', $tag['file'], $tag['line']);
+ return false;
}
if ($this->Stack[$this->Level]->Tag['name'] != $tag['name']) {
$opening_tag = $this->Stack[$this->Level]->Tag;
$this->Application->handleError(E_USER_ERROR,
'Closing tag '.$this->TagInfo($tag).' does not match
opening tag at current nesting level ('.$this->TagInfo($opening_tag).'
opened at line '.$opening_tag['line'].')', $tag['file'], $tag['line']);
+ return false;
}
$o .= $this->Stack[$this->Level]->Close($tag); // DO NOT use $this->Level-- here because it's used inside Close
$this->Level--;
@@ -143,14 +154,18 @@
else { // regular tags - just compile
if (!$tag['is_closing']) {
$this->Application->handleError(E_USER_ERROR, 'Tag without a handler: '.$this->TagInfo($tag).' - probably missing <empty /> tag closing', $tag['file'], $tag['line']);
+ return false;
}
if ($this->Level > 0) $o .= $this->Stack[$this->Level]->PassThrough($tag);
if (!$tag['processed']) {
- $o .= ''.'php '.$this->CompileTag($tag)." ?>\n";
+ $compiled = $this->CompileTag($tag);
+ if ($compiled === false) return false;
+ $o .= ''.'php '.$compiled." ?>\n";
}
}
$this->Buffers[$this->Level] .= $o;
+ return true;
}
function TagInfo($tag, $with_params=false)
@@ -191,6 +206,7 @@
$p =& $this->GetProcessor($prefix);
if (!$p->CheckTag($tag['name'], $tag['prefix'])) {
$this->Application->handleError(E_USER_ERROR, 'Unknown tag: '.$this->TagInfo($tag).' - incorrect tag name or prefix ', $tag['file'], $tag['line']);
+ return false;
}
}
return $code;
@@ -208,7 +224,7 @@
}
if (!$pre_parsed || !$pre_parsed['active'] || defined('DBG_NPARSER_FORCE_COMPILE') && DBG_NPARSER_FORCE_COMPILE) {
$inc_parser =& new NParser();
- $inc_parser->Compile($pre_parsed);
+ if (!$inc_parser->Compile($pre_parsed)) return false;
}
return $pre_parsed;
}