Merge pull request #702 from th-h/thh-plugin-comments

[plugin_comments] Don't strip HTML unconditionally.
This commit is contained in:
Thomas Hochstein 2020-04-24 15:25:40 +02:00 committed by GitHub
commit e60dd8dd2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,8 @@
Version 1.17:
------------------------------------------------------------------------
* Fix: Don't strip HTML tags from comment body before truncating if
serendipity_event_unstrip_tags is active, so it may actually
preserve the tags (and replace them with entities).
Version 1.16: Version 1.16:
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Fix: wordwrap at word boundaries instead of "truncating" the lines * Fix: wordwrap at word boundaries instead of "truncating" the lines

View File

@ -20,7 +20,7 @@ class serendipity_plugin_comments extends serendipity_plugin
$propbag->add('description', PLUGIN_COMMENTS_BLAHBLAH); $propbag->add('description', PLUGIN_COMMENTS_BLAHBLAH);
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('author', 'Garvin Hicking, Tadashi Jokagi, Judebert, G. Brockhaus'); $propbag->add('author', 'Garvin Hicking, Tadashi Jokagi, Judebert, G. Brockhaus');
$propbag->add('version', '1.16'); $propbag->add('version', '1.17');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '1.6', 'serendipity' => '1.6',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -193,11 +193,17 @@ class serendipity_plugin_comments extends serendipity_plugin
if ($sql && is_array($sql)) { if ($sql && is_array($sql)) {
foreach($sql AS $key => $row) { foreach($sql AS $key => $row) {
# don't strip HTML tags if serendipity_event_unstrip_tags is active
if (!class_exists('serendipity_event_unstrip_tags')) {
$comment = strip_tags($row['comment']);
} else {
$comment = $row['comment'];
}
# truncate comment to $max_chars # truncate comment to $max_chars
if (function_exists('mb_strimwidth')) { if (function_exists('mb_strimwidth')) {
$comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET); $comment = mb_strimwidth($comment, 0, $max_chars, " [...]", LANG_CHARSET);
} else { } else {
$comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1); $comments = wordwrap($comment, $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments); $aComment = explode('@@@', $comments);
$comment = $aComment[0]; $comment = $aComment[0];
if (count($aComment) > 1) { if (count($aComment) > 1) {