phpBB

Code Changes

File: includes/message_parser.php

  Unmodified   Added   Modified   Removed
Line 791Line 791
				else if (preg_match('#^quote(?:="(.*?)")?$#is', $buffer, $m) && substr($out, -1, 1) == '[')
{
$this->parsed_items['quote']++;

				else if (preg_match('#^quote(?:="(.*?)")?$#is', $buffer, $m) && substr($out, -1, 1) == '[')
{
$this->parsed_items['quote']++;


// the buffer holds a valid opening tag
if ($config['max_quote_depth'] && sizeof($close_tags) >= $config['max_quote_depth'])
{
if ($config['max_quote_depth'] == 1)
{
// Depth 1 - no nesting is allowed
$error_ary['quote_depth'] = $user->lang('QUOTE_NO_NESTING');
}
else
{
// There are too many nested quotes
$error_ary['quote_depth'] = $user->lang('QUOTE_DEPTH_EXCEEDED', (int) $config['max_quote_depth']);
}

$out .= $buffer . $tok;
$tok = '[]';
$buffer = '';

continue;
}


 
					array_push($close_tags, '/quote:' . $this->bbcode_uid);

if (isset($m[1]) && $m[1])

					array_push($close_tags, '/quote:' . $this->bbcode_uid);

if (isset($m[1]) && $m[1])

Line 1193Line 1171
		* @var bool		return					Do we return after the event is triggered if $warn_msg is not empty
* @var array warn_msg Array of the warning messages
* @since 3.1.2-RC1

		* @var bool		return					Do we return after the event is triggered if $warn_msg is not empty
* @var array warn_msg Array of the warning messages
* @since 3.1.2-RC1

		* @change 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid

		* @changed 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid

		*/
$message = $this->message;
$warn_msg = $this->warn_msg;

		*/
$message = $this->message;
$warn_msg = $this->warn_msg;

Line 1275Line 1253
			$character_list = implode('<br />', $matches[0]);
$this->warn_msg[] = $user->lang('UNSUPPORTED_CHARACTERS_MESSAGE', $character_list);
return $update_this_message ? $this->warn_msg : $return_message;

			$character_list = implode('<br />', $matches[0]);
$this->warn_msg[] = $user->lang('UNSUPPORTED_CHARACTERS_MESSAGE', $character_list);
return $update_this_message ? $this->warn_msg : $return_message;

 
		}

// Remove quotes that are nested too deep
if ($config['max_quote_depth'] > 0)
{
$this->remove_nested_quotes($config['max_quote_depth']);

		}

// Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length.

		}

// Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length.

Line 1316Line 1300
			$tmp_message = $this->message;
$return_message = &$this->message;
}

			$tmp_message = $this->message;
$return_message = &$this->message;
}

 

$text = $this->message;
$uid = $this->bbcode_uid;

/**
* Event to modify the text before it is parsed
*
* @event core.modify_format_display_text_before
* @var string text The message text to parse
* @var string uid The bbcode uid
* @var bool allow_bbcode Do we allow bbcodes
* @var bool allow_magic_url Do we allow magic urls
* @var bool allow_smilies Do we allow smilies
* @var bool update_this_message Do we update the internal message
* with the parsed result
* @since 3.1.6-RC1
*/
$vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message');
extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_before', compact($vars)));

$this->message = $text;
$this->bbcode_uid = $uid;
unset($text, $uid);


if ($this->message_status == 'plain')
{


if ($this->message_status == 'plain')
{

Line 1815Line 1822
		$this->message = $poll['poll_title'];
$this->bbcode_bitfield = $bbcode_bitfield;


		$this->message = $poll['poll_title'];
$this->bbcode_bitfield = $bbcode_bitfield;


		$poll['poll_options'] = explode("\n", trim($poll['poll_option_text']));

		$poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text']));

		$poll['poll_options_size'] = sizeof($poll['poll_options']);

if (!$poll['poll_title'] && $poll['poll_options_size'])

		$poll['poll_options_size'] = sizeof($poll['poll_options']);

if (!$poll['poll_title'] && $poll['poll_options_size'])

Line 1853Line 1860
		}

$poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']);

		}

$poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']);

 
	}

/**
* Remove nested quotes at given depth in current parsed message
*
* @param integer $max_depth Depth limit
* @return null
*/
public function remove_nested_quotes($max_depth)
{
// Capture all [quote] and [/quote] tags
preg_match_all('(\\[/?quote(?:=&quot;(.*?)&quot;)?:' . $this->bbcode_uid . '\\])', $this->message, $matches, PREG_OFFSET_CAPTURE);

// Iterate over the quote tags to mark the ranges that must be removed
$depth = 0;
$ranges = array();
$start_pos = 0;
foreach ($matches[0] as $match)
{
if ($match[0][1] === '/')
{
--$depth;
if ($depth == $max_depth)
{
$end_pos = $match[1] + strlen($match[0]);
$length = $end_pos - $start_pos;
$ranges[] = array($start_pos, $length);
}
}
else
{
++$depth;
if ($depth == $max_depth + 1)
{
$start_pos = $match[1];
}
}
}

foreach (array_reverse($ranges) as $range)
{
list($start_pos, $length) = $range;
$this->message = substr_replace($this->message, '', $start_pos, $length);
}

	}

/**

	}

/**