From 46f50248f01c03bb4fefd181c5e5ac594fac4774 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Thu, 16 Aug 2012 09:05:19 -0500 Subject: Don't require closing tag for tags that don't need it. --- inc/display.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 264fde60..6394c711 100644 --- a/inc/display.php +++ b/inc/display.php @@ -190,9 +190,12 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { // remove broken HTML entity at the end (if existent) $body = preg_replace('/&[^;]+$/', '', $body); + $tags_no_close_needed = array("colgroup", "dd", "dt", "li", "optgroup", "option", "p", "tbody", "td", "tfoot", "th", "thead", "tr", "br", "img"); + // Close any open tags foreach ($tags as &$tag) { - $body .= ""; + if (!in_array($tag, $tags_no_close_needed)) + $body .= ""; } } else { // remove broken HTML entity at the end (if existent) -- cgit v1.3 From 948dfe8555e06b2f900a92678faff918c2ab95b6 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Mon, 14 Jan 2013 19:11:55 -0600 Subject: Don't truncate inside an HTML comment! --- inc/display.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 6394c711..f4e1151e 100644 --- a/inc/display.php +++ b/inc/display.php @@ -155,6 +155,11 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { $max_lines = $config['body_truncate']; if ($max_chars === false) $max_chars = $config['body_truncate_char']; + + // We don't want to risk truncating in the middle of an HTML comment. + // It's easiest just to remove them all first. + $body = preg_replace('//s', '', $body); + $original_body = $body; $lines = substr_count($body, '
'); -- cgit v1.3 From b63d94838da090cddb98f1b7f19268a32c6a75d8 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 18 Jan 2013 18:10:14 -0600 Subject: Do truncation by actual character count. Using substr can cut a multi-byte character in half. Also, if a long post with many multi-byte characters was reported, then the mod interface would temporarily extend the body_truncate_char setting to be sure to cover all of the *characters* in the report, but this function would interpret body_truncate_char as a number of *bytes*, so sometimes the end of the report's appended html would be cut off. --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index f4e1151e..85c21e7c 100644 --- a/inc/display.php +++ b/inc/display.php @@ -170,7 +170,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { $body = $m[0]; } - $body = substr($body, 0, $max_chars); + $body = mb_substr($body, 0, $max_chars); if ($body != $original_body) { // Remove any corrupt tags at the end -- cgit v1.3 From 9007640e88543f972321cbd4f5561e8666c51afd Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Wed, 16 Jan 2013 16:32:24 -0600 Subject: Don't do anything if a mod link is middle-clicked. This lets Chrome users open mod actions in a new tab by middle-clicking, as Chrome still calls the onclick event when middle-clicking unlike Firefox. --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 85c21e7c..ef952ca2 100644 --- a/inc/display.php +++ b/inc/display.php @@ -216,7 +216,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { function secure_link_confirm($text, $title, $confirm_message, $href) { global $config; - return '' . $text . ''; + return '' . $text . ''; } function secure_link($href) { return $href . '/' . make_secure_link_token($href); -- cgit v1.3 From 7eef94e04e3f80ae776cd2c02ca29dd93945a47f Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 2 Nov 2012 22:29:11 -0600 Subject: Fix transforming links to mod links in OP posts. Similar regexes are called for threads and posts, but they differed needlessly, and the thread regex would drop anything between the `