diff options
| author | czaks <marcin@6irc.net> | 2013-07-31 21:36:54 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-07-31 21:36:54 -0400 |
| commit | cefd5517ac1a532214ac2f47485f63958c87ce25 (patch) | |
| tree | 526091d0254d32ae2db80675d9dadf050c16ac8d /inc | |
| parent | e93d5b2f8e033735ca40a9d3a44771be9f3842c8 (diff) | |
| parent | 232f4ff8680e81dbee3902c01af6c702555fbc0f (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/functions.php | 24 | ||||
| -rw-r--r-- | inc/mod/pages.php | 9 |
2 files changed, 23 insertions, 10 deletions
diff --git a/inc/functions.php b/inc/functions.php index e57fd32a..dfc2fa92 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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) { diff --git a/inc/mod/pages.php b/inc/mod/pages.php index d533460e..3ff6a9b1 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1222,7 +1222,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { $_POST['message'] = str_replace('%LENGTH%', strtoupper($length_english), $_POST['message']); $query = prepare(sprintf('UPDATE `posts_%s` SET `body_nomarkup` = CONCAT(`body_nomarkup`, :body_nomarkup) WHERE `id` = :id', $board)); $query->bindValue(':id', $post); - $query->bindValue(':body_nomarkup', sprintf("\n<tinyboard ban message>%s</tinyboard>", $_POST['message'])); + $query->bindValue(':body_nomarkup', sprintf("\n<tinyboard ban message>%s</tinyboard>", utf8tohtml($_POST['message']))); $query->execute() or error(db_error($query)); rebuildPost($post); @@ -1302,10 +1302,13 @@ function mod_edit_post($board, $edit_raw_html, $postID) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']); } else { if ($config['minify_html']) { - $post['body_nomarkup'] = str_replace("\n", '
', $post['body_nomarkup']); - $post['body'] = str_replace("\n", '
', $post['body']); + // $post['body_nomarkup'] = str_replace("\n", '
', $post['body_nomarkup']); + // $post['body'] = str_replace("\n", '
', $post['body']); } + // Minifying this page causes an issue with newlines in the textarea. This is a temporary solution. + $config['minify_html'] = false; + mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); } } |
