Joomla!-开源天空

2008-12-05
首页 专栏热点 Joomla! 源代码分析 fireboard论坛,发帖内容中不能贴程序代码或者html代码的原因追溯


fireboard论坛,发帖内容中不能贴程序代码或者html代码的原因追溯

E-mail

已经抱怨fireboard 的bbcode很久了,好多朋友都抱怨过这种情况,在论坛中想用bbcode 贴一些php供大家参考,结果经常贴出来后,却面目全非。就像唐伯虎点秋香里中了面目全非脚一样。

 一直怀疑是fireboard 的bbcode有问题,今天有空查了一下原因,却发现跟我的预想不同,问题处在 legacy模式中的函数 mosGetparam ,这个函数代码如下:

 

function mosGetParam( &$arr, $name, $def=null, $mask=0 )
{
 // Static input filters for specific settings
 static $noHtmlFilter = null;
 static $safeHtmlFilter = null;
 $var = JArrayHelper::getValue( $arr, $name, $def, '' );
 // If the no trim flag is not set, trim the variable
 if (!($mask & 1) && is_string($var)) {
  $var = trim($var);
 }
 // Now we handle input filtering
 if ($mask & 2) {
  // If the allow html flag is set, apply a safe html filter to the variable
  if (is_null($safeHtmlFilter)) {
   $safeHtmlFilter = & JFilterInput::getInstance(null, null, 1, 1);
  }
  $var = $safeHtmlFilter->clean($var, 'none');
 } elseif ($mask & 4) {
  // If the allow raw flag is set, do not modify the variable
  $var = $var;
 } else {
  // Since no allow flags were set, we will apply the most strict filter to the variable
  if (is_null($noHtmlFilter)) {
   $noHtmlFilter = & JFilterInput::getInstance(/* $tags, $attr, $tag_method, $attr_method, $xss_auto */);
  }
  $var = $noHtmlFilter->clean($var, 'none');
 }
 return $var;
}

 显然为了安全,这个函数对输入的参数进行了过滤,相当于我们Joomla! 1.5中的 inputfilter 吧。而在fireboard 的 fireboad.php 以及post.php中,都有这样的使用的地方:

$message = mosGetParam($_REQUEST, 'message');

 这样引用自然就会进入最严格的过滤。我们当然可以改为

$message = mosGetParam($_REQUEST, 'message', '',4);

 就不会发生过滤了,但是这样做的后果就是安全性降低了,还需要后续的手段进行必要的安全过滤。

 

 



收藏此文章:
Digg! Reddit! Del.icio.us! JoomlaVote! Google! Live! Facebook! StumbleUpon! Yahoo! Free social bookmarking plugins and extensions for Joomla! websites!
User Reviews(7)
 我也试试,灌代码一壶
作者:purity 星期三, 27 八月 2008 01:39

triggerEvent('onCaptcha_Display', array($Ok));
if (!$Ok) {
echo "Error displaying Captcha";
}
}
?>
 回复:[文章评论]--fireboard论坛,发帖内容中不能贴程序代码或者html代码的原因追溯
作者:purity 星期三, 27 八月 2008 01:40
[code]

<?
function displaycaptcha() {
global $mainframe;
$Ok = null;
$mainframe->triggerEvent(\'onCaptcha_Display\', array($Ok));
if (!$Ok) {
echo \"<br/>Error displaying Captcha<br/>\";
}
}
?>

[/code]
 回复:[文章评论]--fireboard论坛,发帖内容中不能贴程序代码或者html代码的原因追溯
作者:purity 星期三, 27 八月 2008 01:41
老大,你的文章评论的部分还不行!
 谁说不行,你看看
作者:admin 星期三, 27 八月 2008 01:48
[code]

triggerEvent(\'onCaptcha_Display\', array($Ok));
if (!$Ok) {
echo \"Error displaying Captcha\";
}
}
?>

[/code]
 再来一次试试
作者:admin 星期三, 27 八月 2008 01:51
[code]

<?
function displaycaptcha() {
global $mainframe;
$Ok = null;
$mainframe->triggerEvent(\'onCaptcha_Display\', array($Ok));
if (!$Ok) {
echo \"<br/>Error displaying Captcha<br/>\";
}
}
?>

[/code]
 关键是文章的评论页面没有bbcode解析
作者:purity 星期三, 27 八月 2008 01:53
这个不太好!
 回复:关键是文章的评论页面没有bbcode解析
作者:angang523409 星期三, 27 八月 2008 04:20
水贴,水贴·····:silly: :woohoo:

发表您的文章评论

您的姓名 (昵称)
标题:
评分: 很差一般较好很好
评论:
验证码:
请输入验证码