summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-02-11 18:53:27 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-02-11 18:53:27 +1100
commitae76ddb0795cbeb1c7b8f7b2d203a518fc828403 (patch)
treef492a18245e7cd5e674589596936a4747264b0af /inc
parent5c847c75ac9e39a386e0cd4a55164e03091b5cdd (diff)
Fixed issue #34: "HTML entities can be cut in half when truncating posts"
Diffstat (limited to 'inc')
-rw-r--r--inc/display.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/inc/display.php b/inc/display.php
index 7f0226d4..b8a91676 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -156,6 +156,7 @@
function truncate($body, $url, $max_lines = false, $max_chars = false) {
global $config;
+
if($max_lines === false)
$max_lines = $config['body_truncate'];
if($max_chars === false)
@@ -192,11 +193,18 @@
}
}
+ // remove broken HTML entity at the end (if existent)
+ $body = preg_replace('/&[^;]+$/', '', $body);
+
// Close any open tags
foreach($tags as &$tag) {
$body .= "</{$tag}>";
}
+ } else {
+ // remove broken HTML entity at the end (if existent)
+ $body = preg_replace('/&[^;]+$/', '', $body);
}
+
$body .= '<span class="toolong">Post too long. Click <a href="' . $url . '">here</a> to view the full text.</span>';
}