mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Fix (hopefully anyway :) for nested code tag issues with bbcode
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2590 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
5efffc9c3d
commit
95197ab48b
2 changed files with 19 additions and 22 deletions
|
@ -483,20 +483,34 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_
|
||||||
// Mark the lowest nesting level if needed.
|
// Mark the lowest nesting level if needed.
|
||||||
if ($mark_lowest_level && ($curr_nesting_depth == 1))
|
if ($mark_lowest_level && ($curr_nesting_depth == 1))
|
||||||
{
|
{
|
||||||
|
if ($open_tag[0] == '[code]')
|
||||||
|
{
|
||||||
|
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#');
|
||||||
|
$code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}');
|
||||||
|
$between_tags = preg_replace($code_entities_match, $code_entities_replace, $between_tags);
|
||||||
|
}
|
||||||
$text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$curr_nesting_depth:$uid]";
|
$text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$curr_nesting_depth:$uid]";
|
||||||
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$curr_nesting_depth:$uid]";
|
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$curr_nesting_depth:$uid]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($open_is_regexp)
|
if ($open_tag[0] == '[code]')
|
||||||
{
|
{
|
||||||
$text = $before_start_tag . $start_tag;
|
$text = $before_start_tag . '[code]';
|
||||||
|
$text .= $between_tags . '[/code]';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]";
|
if ($open_is_regexp)
|
||||||
|
{
|
||||||
|
$text = $before_start_tag . $start_tag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]";
|
||||||
|
}
|
||||||
|
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]";
|
||||||
}
|
}
|
||||||
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= $after_end_tag;
|
$text .= $after_end_tag;
|
||||||
|
|
|
@ -108,23 +108,6 @@ function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid
|
||||||
|
|
||||||
if( $bbcode_on && $bbcode_uid != '' )
|
if( $bbcode_on && $bbcode_uid != '' )
|
||||||
{
|
{
|
||||||
$tmp_message = $message;
|
|
||||||
if ( ($match_count = preg_match_all('#^(.*?)\[code\](.*?)\[\/code\](.*?)$#is', $tmp_message, $match)) )
|
|
||||||
{
|
|
||||||
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#');
|
|
||||||
$code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}');
|
|
||||||
|
|
||||||
$message = '';
|
|
||||||
|
|
||||||
for($i = 0; $i < $match_count; $i++)
|
|
||||||
{
|
|
||||||
$message .= $match[1][$i] . '[code]' . preg_replace($code_entities_match, $code_entities_replace, $match[2][$i]) . '[/code]';
|
|
||||||
$tmp_message = $match[3][$i];
|
|
||||||
}
|
|
||||||
|
|
||||||
$message .= $tmp_message;
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = bbencode_first_pass($message, $bbcode_uid);
|
$message = bbencode_first_pass($message, $bbcode_uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,4 +819,4 @@ function generate_smilies($mode, $page_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue