aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/message_parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/message_parser.php')
-rw-r--r--phpBB/includes/message_parser.php51
1 files changed, 28 insertions, 23 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 6e601e1499..674e13de49 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -198,7 +198,7 @@ class bbcode_firstpass extends bbcode
if (!$this->check_bbcode('size', $in))
{
- return '';
+ return $in;
}
if ($config['max_' . $this->mode . '_font_size'] && $config['max_' . $this->mode . '_font_size'] < $stx)
@@ -224,7 +224,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('color', $in))
{
- return '';
+ return $in;
}
return '[color=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/color:' . $this->bbcode_uid . ']';
@@ -237,7 +237,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('u', $in))
{
- return '';
+ return $in;
}
return '[u:' . $this->bbcode_uid . ']' . $in . '[/u:' . $this->bbcode_uid . ']';
@@ -250,7 +250,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('b', $in))
{
- return '';
+ return $in;
}
return '[b:' . $this->bbcode_uid . ']' . $in . '[/b:' . $this->bbcode_uid . ']';
@@ -263,7 +263,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('i', $in))
{
- return '';
+ return $in;
}
return '[i:' . $this->bbcode_uid . ']' . $in . '[/i:' . $this->bbcode_uid . ']';
@@ -278,7 +278,7 @@ class bbcode_firstpass extends bbcode
if (!$this->check_bbcode('img', $in))
{
- return '';
+ return $in;
}
$in = trim($in);
@@ -340,7 +340,7 @@ class bbcode_firstpass extends bbcode
if (!$this->check_bbcode('flash', $in))
{
- return '';
+ return $in;
}
$in = trim($in);
@@ -377,7 +377,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('attachment', $in))
{
- return '';
+ return $in;
}
return '[attachment=' . $stx . ':' . $this->bbcode_uid . ']<!-- ia' . $stx . ' -->' . trim($in) . '<!-- ia' . $stx . ' -->[/attachment:' . $this->bbcode_uid . ']';
@@ -457,7 +457,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('code', $in))
{
- return '';
+ return $in;
}
// We remove the hardcoded elements from the code block here because it is not used in code blocks
@@ -550,7 +550,7 @@ class bbcode_firstpass extends bbcode
{
if (!$this->check_bbcode('list', $in))
{
- return '';
+ return $in;
}
// $tok holds characters to stop at. Since the string starts with a '[' we'll get everything up to the first ']' which should be the opening [list] tag
@@ -684,7 +684,8 @@ class bbcode_firstpass extends bbcode
* #14667 - [quote]test[/quote] test ] and [ test [quote]test[/quote] (correct: parsed)
* #14770 - [quote="["]test[/quote] (correct: parsed)
* [quote="[i]test[/i]"]test[/quote] (correct: parsed)
- * [quote="[quote]test[/quote]"]test[/quote] (correct: NOT parsed)
+ * [quote="[quote]test[/quote]"]test[/quote] (correct: parsed - Username displayed as [quote]test[/quote])
+ * #20735 - [quote]test[/[/b]quote] test [/quote][/quote] test - (correct: quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted)
*/
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
@@ -737,7 +738,7 @@ class bbcode_firstpass extends bbcode
$out .= ' ';
}*/
}
- else if (preg_match('#^quote(?:=&quot;(.*?)&quot;)?$#is', $buffer, $m))
+ else if (preg_match('#^quote(?:=&quot;(.*?)&quot;)?$#is', $buffer, $m) && substr($out, -1, 1) == '[')
{
$this->parsed_items['quote']++;
@@ -913,9 +914,14 @@ class bbcode_firstpass extends bbcode
$url = ($var1) ? $var1 : $var2;
- if (!$url || ($var1 && !$var2))
+ if ($var1 && !$var2)
{
- return '';
+ $var2 = $var1;
+ }
+
+ if (!$url)
+ {
+ return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]';
}
$valid = false;
@@ -978,7 +984,7 @@ class bbcode_firstpass extends bbcode
// Is the user trying to link to a php file in this domain and script path?
if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false)
{
- $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
+ $server_name = $user->host;
// Forcing server vars is the only way to specify/override the protocol
if ($config['force_server_vars'] || !$server_name)
@@ -1079,19 +1085,19 @@ class parse_message extends bbcode_firstpass
if ($config['max_' . $mode . '_chars'] > 0)
{
$msg_len = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message));
-
+
if ((!$msg_len && $mode !== 'sig') || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars'])
{
$this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, $config['max_' . $mode . '_chars']);
- return $this->warn_msg;
+ return (!$update_this_message) ? $return_message : $this->warn_msg;
}
}
// Check for "empty" message
- if ($mode !== 'sig' && !utf8_clean_string($this->message))
+ if ($mode !== 'sig' && utf8_clean_string($this->message) === '')
{
$this->warn_msg[] = $user->lang['TOO_FEW_CHARS'];
- return $this->warn_msg;
+ return (!$update_this_message) ? $return_message : $this->warn_msg;
}
// Prepare BBcode (just prepares some tags for better parsing)
@@ -1140,7 +1146,7 @@ class parse_message extends bbcode_firstpass
if ($config['max_' . $mode . '_urls'] && $num_urls > $config['max_' . $mode . '_urls'])
{
$this->warn_msg[] = sprintf($user->lang['TOO_MANY_URLS'], $config['max_' . $mode . '_urls']);
- return $this->warn_msg;
+ return (!$update_this_message) ? $return_message : $this->warn_msg;
}
if (!$update_this_message)
@@ -1249,7 +1255,7 @@ class parse_message extends bbcode_firstpass
$match = $replace = array();
// NOTE: obtain_* function? chaching the table contents?
-
+
// For now setting the ttl to 10 minutes
switch ($db->sql_layer)
{
@@ -1259,7 +1265,7 @@ class parse_message extends bbcode_firstpass
FROM ' . SMILIES_TABLE . '
ORDER BY LEN(code) DESC';
break;
-
+
case 'firebird':
$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
@@ -1597,7 +1603,6 @@ class parse_message extends bbcode_firstpass
$this->message = $poll['poll_option_text'];
$bbcode_bitfield = $this->bbcode_bitfield;
-
$poll['poll_option_text'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false);
$bbcode_bitfield = base64_encode(base64_decode($bbcode_bitfield) | base64_decode($this->bbcode_bitfield));