aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_privmsgs.php2
-rw-r--r--phpBB/includes/message_parser.php74
-rw-r--r--phpBB/includes/template.php56
3 files changed, 60 insertions, 72 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 2dad1e6477..2532cafd1a 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -325,7 +325,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$row['friend'] = (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0;
$row['foe'] = (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0;
$row['user_in_group'] = $user->data['group_id'];
-
+
// Check Rule - this should be very quick since we have all informations we need
$is_match = false;
foreach ($user_rules as $rule_row)
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 097cece8dc..0d2a1d19a5 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -103,7 +103,7 @@ class bbcode_firstpass extends bbcode
'attachment'=> array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")),
'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")),
'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")),
- 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url=?(.*?)?\](.*?)\[/url\]#ise' => "\$this->validate_url('\$1', '\$2')")),
+ 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#ie' => "\$this->validate_url('\$2', '\$3')")),
'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](https?://)([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)\[/img\]#ie' => "\$this->bbcode_img('\$1\$2')")),
'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?[1-2]?[0-9])\](.*?)\[/size\]#is' => "\$this->bbcode_size('\$1', '\$2')")),
'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]!is' => "\$this->bbcode_color('\$1', '\$2')")),
@@ -113,7 +113,7 @@ class bbcode_firstpass extends bbcode
'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')"))
);
- $this->parsed_items = array('code' => 0, 'quote' => 0, 'attachment' => 0, 'url' => 0, 'email' => 0, 'img' => 0, 'flash' => 0);
+ $this->parsed_items = array('code' => 0, 'quote' => 0, 'attachment' => 0, 'b' => 0, 'i' => 0, 'url' => 0, 'img' => 0, 'size' => 0, 'color' => 0, 'u' => 0, 'list' => 0, 'email' => 0, 'flash' => 0);
if (!is_array($rowset))
{
@@ -139,23 +139,33 @@ class bbcode_firstpass extends bbcode
}
}
- function bbcode_size($stx, $in)
+ function check_bbcode($bbcode, &$in)
{
$in = trim($in);
if (!$in)
{
- return '';
+ return false;
}
+
+ $this->parsed_items[$bbcode]++;
+ return true;
+ }
+
+ function bbcode_size($stx, $in)
+ {
+ if (!$this->check_bbcode('size', $in))
+ {
+ return '';
+ }
+
return '[size' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/size:' . $this->bbcode_uid . ']';
}
function bbcode_color($stx, $in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('color', $in))
{
return '';
}
@@ -165,9 +175,7 @@ class bbcode_firstpass extends bbcode
function bbcode_underline($in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('u', $in))
{
return '';
}
@@ -177,9 +185,7 @@ class bbcode_firstpass extends bbcode
function bbcode_strong($in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('b', $in))
{
return '';
}
@@ -189,9 +195,7 @@ class bbcode_firstpass extends bbcode
function bbcode_italic($in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('i', $in))
{
return '';
}
@@ -201,48 +205,33 @@ class bbcode_firstpass extends bbcode
function bbcode_img($in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('img', $in))
{
return '';
}
- $this->parsed_items['img']++;
-
- $out = '[img:' . $this->bbcode_uid . ']' . $in . '[/img:' . $this->bbcode_uid . ']';
- return $out;
+ return '[img:' . $this->bbcode_uid . ']' . $in . '[/img:' . $this->bbcode_uid . ']';
}
function bbcode_flash($width, $height, $in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('flash', $in))
{
return '';
}
-
- $this->parsed_items['flash']++;
- $out = '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $in . '[/flash:' . $this->bbcode_uid . ']';
- return $out;
+ return '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $in . '[/flash:' . $this->bbcode_uid . ']';
}
// Hardcode inline attachments [ia]
function bbcode_attachment($stx, $in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('attachment', $in))
{
return '';
}
- $this->parsed_items['attachment']++;
-
- $out = '[attachment=' . $stx . ':' . $this->bbcode_uid . ']<!-- ia' . $stx . ' -->' . $in . '<!-- ia' . $stx . ' -->[/attachment:' . $this->bbcode_uid . ']';
- return $out;
+ return '[attachment=' . $stx . ':' . $this->bbcode_uid . ']<!-- ia' . $stx . ' -->' . $in . '<!-- ia' . $stx . ' -->[/attachment:' . $this->bbcode_uid . ']';
}
// Expects the argument to start right after the opening [code] tag and to end with [/code]
@@ -377,9 +366,7 @@ class bbcode_firstpass extends bbcode
// Expects the argument to start with a tag
function bbcode_parse_list($in)
{
- $in = trim($in);
-
- if (!$in)
+ if (!$this->check_bbcode('list', $in))
{
return '';
}
@@ -639,6 +626,7 @@ class bbcode_firstpass extends bbcode
{
$retval = '[email:' . $this->bbcode_uid . ']' . $email . '[/email:' . $this->bbcode_uid . ']';
}
+
return $retval;
}
@@ -677,7 +665,7 @@ class bbcode_firstpass extends bbcode
$url = 'http://' . $url;
}
- return ($var1) ? '[url=' . $url . ':' . $this->bbcode_uid . ']' . stripslashes($var2) . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']';
+ return ($var1) ? '[url=' . str_replace(array(']', '['), array('&#93;', '&#91;'), $url) . ':' . $this->bbcode_uid . ']' . stripslashes($var2) . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']';
}
return '[url' . (($var1) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]';
@@ -1098,7 +1086,7 @@ class parse_message extends bbcode_firstpass
{
if ($edit_comment)
{
- $actual_comment_list = request_var('comment_list', '');
+ $actual_comment_list = request_var('comment_list', array(''));
foreach ($actual_comment_list as $index => $entry)
{
@@ -1161,7 +1149,7 @@ class parse_message extends bbcode_firstpass
{
if ($type == 's')
{
- $this->attachment_data[$pos][$var] = htmlspecialchars(trim(stripslashes(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $this->attachment_data[$pos][$var]))));
+ $this->attachment_data[$pos][$var] = trim(htmlspecialchars(str_replace(array("\r\n", "\r", '\xFF'), array("\n", "\n", ' '), stripslashes($this->attachment_data[$pos][$var]))));
}
else
{
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 90f635f5a0..935bff806d 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -694,37 +694,37 @@ class template
//
function compile_tag_if($tag_args, $elseif)
{
- /* Tokenize args for 'if' tag. */
- preg_match_all('/(?:
- "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
- \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
- [(),] |
- [^\s(),]+)/x', $tag_args, $match);
+ /* Tokenize args for 'if' tag. */
+ preg_match_all('/(?:
+ "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
+ \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
+ [(),] |
+ [^\s(),]+)/x', $tag_args, $match);
- $tokens = $match[0];
- $is_arg_stack = array();
+ $tokens = $match[0];
+ $is_arg_stack = array();
- for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
+ for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
{
$token = &$tokens[$i];
switch ($token)
{
- case '!':
- case '%':
- case '!==':
- case '==':
- case '===':
- case '>':
- case '<':
- case '!=':
- case '<>':
- case '<<':
- case '>>':
- case '<=':
- case '>=':
- case '&&':
- case '||':
+ case '!':
+ case '%':
+ case '!==':
+ case '==':
+ case '===':
+ case '>':
+ case '<':
+ case '!=':
+ case '<>':
+ case '<<':
+ case '>>':
+ case '<=':
+ case '>=':
+ case '&&':
+ case '||':
case '|':
case '^':
case '&':
@@ -801,8 +801,8 @@ class template
$token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[3]) . '[\'' . $varrefs[4] . '\']' : (($varrefs[3]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[4] . '\']' : '$this->_tpldata[\'.\'][0][\'' . $varrefs[4] . '\']');
}
break;
- }
- }
+ }
+ }
return (($elseif) ? '} elseif (' : 'if (') . (implode(' ', $tokens) . ') { ');
}
@@ -850,12 +850,12 @@ class template
function compile_tag_include($tag_args)
{
- return "\$this->_tpl_include('$tag_args');";
+ return "\$this->_tpl_include('$tag_args');";
}
function compile_tag_include_php($tag_args)
{
- return "include('" . $this->root . '/' . $tag_args . "');";
+ return "include('" . $this->root . '/' . $tag_args . "');";
}
// This is from Smarty