|
|
@ -1449,9 +1449,10 @@ function markup(&$body, $track_cites = false) { |
|
|
|
$body = str_replace("\r", '', $body); |
|
|
|
$body = utf8tohtml($body); |
|
|
|
|
|
|
|
if (preg_match_all('@<tinyboard ([\w\s]+)>(.+)</tinyboard>@um', $body, $modifiers, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { |
|
|
|
if (preg_match_all('@<tinyboard ([\w\s]+)>(.+?)</tinyboard>@um', $body, $modifiers, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { |
|
|
|
$skip_chars = 0; |
|
|
|
$body_tmp = $body; |
|
|
|
$end_markup = false; |
|
|
|
|
|
|
|
foreach ($modifiers as $modifier) { |
|
|
|
// preg_match_all is not multibyte-safe |
|
|
@ -1464,10 +1465,14 @@ function markup(&$body, $track_cites = false) { |
|
|
|
|
|
|
|
if ($modifier['type'] == 'ban message') { |
|
|
|
// Public ban message |
|
|
|
$replacement = sprintf($config['mod']['ban_message'], $modifier['content']); |
|
|
|
$replacement = sprintf($config['mod']['ban_message'], html_entity_decode($modifier['content'])); |
|
|
|
if ($end_markup) { |
|
|
|
$body .= $replacement; |
|
|
|
} |
|
|
|
} elseif ($modifier['type'] == 'raw html') { |
|
|
|
$body = html_entity_decode($modifier['content']); |
|
|
|
return array(); |
|
|
|
$replacement = ''; |
|
|
|
$end_markup = true; |
|
|
|
} elseif (preg_match('/^escape /', $modifier['type'])) { |
|
|
|
// Escaped (not a real modifier) |
|
|
|
$replacement = '<tinyboard ' . substr($modifier['type'], strlen('escape ')) . '>' . $modifier['content'] . '</tinyboard>'; |
|
|
@ -1476,9 +1481,14 @@ function markup(&$body, $track_cites = false) { |
|
|
|
$replacement = ''; |
|
|
|
} |
|
|
|
|
|
|
|
$body = mb_substr_replace($body, $replacement, $modifier[0][1] + $skip_chars, mb_strlen($modifier[0][0])); |
|
|
|
$skip_chars += mb_strlen($replacement) - mb_strlen($modifier[0][0]); |
|
|
|
if (!$end_markup) { |
|
|
|
$body = mb_substr_replace($body, $replacement, $modifier[0][1] + $skip_chars, mb_strlen($modifier[0][0])); |
|
|
|
$skip_chars += mb_strlen($replacement) - mb_strlen($modifier[0][0]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($end_markup) { |
|
|
|
return array(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1623,7 +1633,7 @@ function markup(&$body, $track_cites = false) { |
|
|
|
} |
|
|
|
|
|
|
|
function escape_markup_modifiers($string) { |
|
|
|
return preg_replace('@<tinyboard ([\w\s]+)>(.+)</tinyboard>@m', '<tinyboard escape $1>$2</tinyboard>', $string); |
|
|
|
return preg_replace('@<tinyboard ([\w\s]+)>@m', '<tinyboard escape $1>', $string); |
|
|
|
} |
|
|
|
|
|
|
|
function utf8tohtml($utf8) { |
|
|
|