When using a template param in an IF statement, the IF statement should be processed if the template param contains the correct value.
However, the statement is always processed as true, because template parameters are applied AFTER the template is parsed rather than before. I think this was to allow NOPARSE to prevent a param from being replaced, but if we wanted that, we could easily obfuscate the param by doing something like:
Code:
[noparse]{{[/noparse]{param|}[noparse]}}[/noparse]
, or using a Template:Triple-Open-Brace/Triple-Close-Brace method. Such a sacrifice is worth keeping IF functional.
Fixed for the next build. In
vault/class/bbcode/template.php, find:
Code:
$this->parser->options['do_html'] = $templateforum['allowhtml'];
$this->parser->options['do_bbcode'] = $templateforum['allowbbcode'];
$this->parser->options['do_smilies'] = $templateforum['allowsmilies'];
$this->parser->options['do_imgcode'] = $templateforum['allowimages'];
if (VAULT_403_COMPAT AND $htmlstate)
{
switch ($htmlstate)
{
case 'on':
$this->parser->options['do_nl2br'] = false;
break;
case 'off':
$this->parser->options['do_html'] = false;
break;
case 'on_nl2br':
$this->parser->options['do_nl2br'] = true;
break;
}
}
else
{
$this->parser->options['do_nl2br'] = true;
}
if (
!$this->parser->options['do_html'] AND
// don't do it if we're looking for other stuff
!$vault->parser['fake_tag_list'] AND
!$vault->parser['converted_text']
)
{
$template_text = htmlspecialchars_uni($template_text);
}
if ($templateforum['allowsmilies'])
{
$template_text = $this->parser->parse_smilies($template_text, $this->parser->options['do_html']);
}
$has_img_tag = ($templateforum['allowbbcode'] ? $this->parser->contains_bbcode_img_tags($text) : 0);
if ($has_img_tag AND !$templateforum['allowimages'])
{
$text = $this->noparse_img($text, $templateforum['allowbbcode'], $has_img_tag);
}
if ($templateforum['allowbbcode'])
{
$template_text = $this->parser->parse_bbcode(
$template_text,
$templateforum['allowsmilies'],
$templ['do_html']
);
}
else if (($_REQUEST['do'] != 'history' OR $_REQUEST['action'] == 'revision') AND !is_class_type($this->parser, 'plaintext'))
{
$template_text = $this->parser->parse_whitespace_newlines($template_text, $this->parser->options['do_nl2br']);
}
$this->parser->options = $orig_option;
$template_text = $this->process_template_params($template_text, $args);
Replace with:
Code:
$do_html = $templateforum['allowhtml'];
$do_bbcode = $templateforum['allowbbcode'];
$do_smilies = $templateforum['allowsmilies'];
$do_imgcode = $templateforum['allowimages'];
if (VAULT_403_COMPAT AND $htmlstate)
{
switch ($htmlstate)
{
case 'on':
$do_nl2br = false;
break;
case 'off':
$do_html = false;
break;
case 'on_nl2br':
$do_nl2br = true;
break;
}
}
else
{
$do_nl2br = true;
}
if (
!$do_html AND
// don't do it if we're looking for other stuff
!$vault->parser['fake_tag_list'] AND
!$vault->parser['converted_text']
)
{
$template_text = htmlspecialchars_uni($template_text);
}
$template_text = $this->process_template_params($template_text, $args);
$this->parser->options['do_html'] = $do_html;
$this->parser->options['do_bbcode'] = $do_bbcode;
$this->parser->options['do_smilies'] = $do_smilies;
$this->parser->options['do_imgcode'] = $do_imgcode;
$this->parser->options['do_nl2br'] = $do_nl2br;
if ($do_smilies)
{
$template_text = $this->parser->parse_smilies($template_text, $do_html);
}
$has_img_tag = ($do_bbcode ? $this->parser->contains_bbcode_img_tags($text) : 0);
if ($has_img_tag AND !$do_imgcode)
{
$text = $this->noparse_img($text, $do_bbcode, $has_img_tag);
}
if ($do_bbcode)
{
$template_text = $this->parser->parse_bbcode(
$template_text,
$templateforum['allowsmilies'],
$templ['do_html']
);
}
else if (($_REQUEST['do'] != 'history' OR $_REQUEST['action'] == 'revision') AND !is_class_type($this->parser, 'plaintext'))
{
$template_text = $this->parser->parse_whitespace_newlines($template_text, $do_nl2br);
}
$this->parser->options = $orig_options;