mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
- fixed url parsing ([] breakage)
git-svn-id: file:///svn/phpbb/trunk@5151 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
4983385f4e
commit
4c207e5510
3 changed files with 60 additions and 72 deletions
|
@ -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')")),
|
'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')")),
|
'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')")),
|
'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')")),
|
'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')")),
|
'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')")),
|
'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')"))
|
'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))
|
if (!is_array($rowset))
|
||||||
{
|
{
|
||||||
|
@ -139,11 +139,23 @@ class bbcode_firstpass extends bbcode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode_size($stx, $in)
|
function check_bbcode($bbcode, &$in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
$in = trim($in);
|
||||||
|
|
||||||
if (!$in)
|
if (!$in)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->parsed_items[$bbcode]++;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bbcode_size($stx, $in)
|
||||||
|
{
|
||||||
|
if (!$this->check_bbcode('size', $in))
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -153,9 +165,7 @@ class bbcode_firstpass extends bbcode
|
||||||
|
|
||||||
function bbcode_color($stx, $in)
|
function bbcode_color($stx, $in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('color', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -165,9 +175,7 @@ class bbcode_firstpass extends bbcode
|
||||||
|
|
||||||
function bbcode_underline($in)
|
function bbcode_underline($in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('u', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -177,9 +185,7 @@ class bbcode_firstpass extends bbcode
|
||||||
|
|
||||||
function bbcode_strong($in)
|
function bbcode_strong($in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('b', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -189,9 +195,7 @@ class bbcode_firstpass extends bbcode
|
||||||
|
|
||||||
function bbcode_italic($in)
|
function bbcode_italic($in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('i', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -201,48 +205,33 @@ class bbcode_firstpass extends bbcode
|
||||||
|
|
||||||
function bbcode_img($in)
|
function bbcode_img($in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('img', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parsed_items['img']++;
|
return '[img:' . $this->bbcode_uid . ']' . $in . '[/img:' . $this->bbcode_uid . ']';
|
||||||
|
|
||||||
$out = '[img:' . $this->bbcode_uid . ']' . $in . '[/img:' . $this->bbcode_uid . ']';
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode_flash($width, $height, $in)
|
function bbcode_flash($width, $height, $in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('flash', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parsed_items['flash']++;
|
return '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $in . '[/flash:' . $this->bbcode_uid . ']';
|
||||||
|
|
||||||
$out = '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $in . '[/flash:' . $this->bbcode_uid . ']';
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardcode inline attachments [ia]
|
// Hardcode inline attachments [ia]
|
||||||
function bbcode_attachment($stx, $in)
|
function bbcode_attachment($stx, $in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('attachment', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parsed_items['attachment']++;
|
return '[attachment=' . $stx . ':' . $this->bbcode_uid . ']<!-- ia' . $stx . ' -->' . $in . '<!-- ia' . $stx . ' -->[/attachment:' . $this->bbcode_uid . ']';
|
||||||
|
|
||||||
$out = '[attachment=' . $stx . ':' . $this->bbcode_uid . ']<!-- ia' . $stx . ' -->' . $in . '<!-- ia' . $stx . ' -->[/attachment:' . $this->bbcode_uid . ']';
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expects the argument to start right after the opening [code] tag and to end with [/code]
|
// 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
|
// Expects the argument to start with a tag
|
||||||
function bbcode_parse_list($in)
|
function bbcode_parse_list($in)
|
||||||
{
|
{
|
||||||
$in = trim($in);
|
if (!$this->check_bbcode('list', $in))
|
||||||
|
|
||||||
if (!$in)
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -639,6 +626,7 @@ class bbcode_firstpass extends bbcode
|
||||||
{
|
{
|
||||||
$retval = '[email:' . $this->bbcode_uid . ']' . $email . '[/email:' . $this->bbcode_uid . ']';
|
$retval = '[email:' . $this->bbcode_uid . ']' . $email . '[/email:' . $this->bbcode_uid . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,7 +665,7 @@ class bbcode_firstpass extends bbcode
|
||||||
$url = 'http://' . $url;
|
$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(']', '['), $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]';
|
return '[url' . (($var1) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]';
|
||||||
|
@ -1098,7 +1086,7 @@ class parse_message extends bbcode_firstpass
|
||||||
{
|
{
|
||||||
if ($edit_comment)
|
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)
|
foreach ($actual_comment_list as $index => $entry)
|
||||||
{
|
{
|
||||||
|
@ -1161,7 +1149,7 @@ class parse_message extends bbcode_firstpass
|
||||||
{
|
{
|
||||||
if ($type == 's')
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -694,37 +694,37 @@ class template
|
||||||
//
|
//
|
||||||
function compile_tag_if($tag_args, $elseif)
|
function compile_tag_if($tag_args, $elseif)
|
||||||
{
|
{
|
||||||
/* Tokenize args for 'if' tag. */
|
/* Tokenize args for 'if' tag. */
|
||||||
preg_match_all('/(?:
|
preg_match_all('/(?:
|
||||||
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
|
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
|
||||||
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
|
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
|
||||||
[(),] |
|
[(),] |
|
||||||
[^\s(),]+)/x', $tag_args, $match);
|
[^\s(),]+)/x', $tag_args, $match);
|
||||||
|
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
$is_arg_stack = array();
|
$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];
|
$token = &$tokens[$i];
|
||||||
|
|
||||||
switch ($token)
|
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 '^':
|
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] . '\']');
|
$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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (($elseif) ? '} elseif (' : 'if (') . (implode(' ', $tokens) . ') { ');
|
return (($elseif) ? '} elseif (' : 'if (') . (implode(' ', $tokens) . ') { ');
|
||||||
}
|
}
|
||||||
|
@ -850,12 +850,12 @@ class template
|
||||||
|
|
||||||
function compile_tag_include($tag_args)
|
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)
|
function compile_tag_include_php($tag_args)
|
||||||
{
|
{
|
||||||
return "include('" . $this->root . '/' . $tag_args . "');";
|
return "include('" . $this->root . '/' . $tag_args . "');";
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is from Smarty
|
// This is from Smarty
|
||||||
|
|
Loading…
Add table
Reference in a new issue