Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

improvement for "Recent Page Comments Widget"


Reply


2 Posts   1111 Views

Avatar
Anatol

126 Posts

25 March 2008 at 11:45am

Edited: 25/03/2008 11:48am

Hi Forum,

I quite liked the Recent Page Comments Widget, so I added it to my blog. However, some spam posts that managed to pass the Akismet spam protection broke my website completely. All pages that contained the Recent Page Comment Widget displayed a rather ugly error message pointing at a blockquote end tag.

This is hardly surprising because the Recent Pages Comments Widget limits the characters that are displayed without considering that it may just leave an unclosed html tag behind. Here is an example:

This is <a href="http://www.i-eat-your-soul.com/annoying/nasty/evil/">spam</a>.

If this is trimmed it becomes

This is <a href="http://www.i-eat
and is rendered as something like
<blockquote>This is <a href="http://www.i-eat</blockquote>

So Silverstripe notices that the html of this page is completely messed up and complains with an error message.

A quick way to fix this is to make a small change in the silverstripe_root_directory/widgets_pagecomments/PageCommentsWidget.php file. Add the bold blue code to line 39:

$holder->setValue(strip_tags($row->Comment));

This should strip out all html tags before the string is trimmed to a certain character length.

Cheers!
Anatol

Avatar
simon_w

Forum Moderator, 474 Posts

26 March 2008 at 7:42am

Updated and uploaded for review.

Thanks (: