Skip to content

Commit

Permalink
Add balanced token checking
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@222441 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Justin Patrin committed Oct 27, 2006
1 parent 593bcde commit b7594ba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Text/Wiki.php
Expand Up @@ -1029,6 +1029,7 @@ function render($format = 'Xhtml')
} else {
// pass through the parsed source text character by character
$this->_block = '';
$tokenStack = array();
$k = strlen($this->source);
for ($i = 0; $i < $k; $i++) {

Expand All @@ -1046,6 +1047,18 @@ function render($format = 'Xhtml')
$this->_block = '';
}

if (isset($opts['type'])) {
if ($opts['type'] == 'start') {
array_push($tokenStack, $rule);
} elseif ($opts['type'] == 'end') {
if ($tokenStack[count($tokenStack) - 1] != $rule) {
return Text_Wiki::error('Unbalanced tokens, check your syntax');
} else {
array_pop($tokenStack);
}
}
}

// yes, get the replacement text for the delimited
// token number and unset the flag.
$key = (int)$key;
Expand Down

0 comments on commit b7594ba

Please sign in to comment.