1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 09:20:58 +01:00

Allow public ban messages on raw HTML posts

This commit is contained in:
Michael Foster 2013-07-31 21:02:26 -04:00
parent 0f9df0ac66
commit a5312ebe89

View File

@ -1423,6 +1423,7 @@ function markup(&$body, $track_cites = false) {
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; $skip_chars = 0;
$body_tmp = $body; $body_tmp = $body;
$end_markup = false;
foreach ($modifiers as $modifier) { foreach ($modifiers as $modifier) {
// preg_match_all is not multibyte-safe // preg_match_all is not multibyte-safe
@ -1436,9 +1437,13 @@ function markup(&$body, $track_cites = false) {
if ($modifier['type'] == 'ban message') { if ($modifier['type'] == 'ban message') {
// Public ban message // Public ban message
$replacement = sprintf($config['mod']['ban_message'], $modifier['content']); $replacement = sprintf($config['mod']['ban_message'], $modifier['content']);
if ($end_markup) {
$body .= $replacement;
}
} elseif ($modifier['type'] == 'raw html') { } elseif ($modifier['type'] == 'raw html') {
$body = html_entity_decode($modifier['content']); $body = html_entity_decode($modifier['content']);
return array(); $replacement = '';
$end_markup = true;
} elseif (preg_match('/^escape /', $modifier['type'])) { } elseif (preg_match('/^escape /', $modifier['type'])) {
// Escaped (not a real modifier) // Escaped (not a real modifier)
$replacement = '<tinyboard ' . substr($modifier['type'], strlen('escape ')) . '>' . $modifier['content'] . '</tinyboard>'; $replacement = '<tinyboard ' . substr($modifier['type'], strlen('escape ')) . '>' . $modifier['content'] . '</tinyboard>';
@ -1447,9 +1452,14 @@ function markup(&$body, $track_cites = false) {
$replacement = ''; $replacement = '';
} }
$body = mb_substr_replace($body, $replacement, $modifier[0][1] + $skip_chars, mb_strlen($modifier[0][0])); if (!$end_markup) {
$skip_chars += mb_strlen($replacement) - mb_strlen($modifier[0][0]); $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();
} }
} }