Keyword

Bug: Simple RSS Feed Reader - Hide Images not working

  • Kulendra
  • Kulendra's Avatar Topic Author
  • Offline
  • New Member
More
14 years 11 months ago #22766 by Kulendra
Hi All
Im using Simple RSS Feed Reader 1.4 for Joomla 1.5 and realized that when I set the 'Hide Images' option to Yes, it still shows up the images. The problem actually came up when I was trying to add a 'class=' property to an img tag. The bug,cause and fix is as follows

Bug:
If Force word limit is set to some value, Hide images option will not work. (Images will be always shown.) Additionally, un-permitted tag stripping that is done inside the module will also not work.

Cause:
Lines 188-210 of mod_jw_srfr.php reads as follows
<?php
		// Assign
		$introtext = $item->get_description();
		$fulltext = $item->get_content();
		
		// Remove images
		if ($srfr_fi_hideimages) {
			$introtext = preg_replace("/<img.+?>/", "", $introtext);
			$fulltext = preg_replace("/<img.+?>/", "", $fulltext);
		}		
			
		// HTML cleanup
		$allowed_tags = "<img><p><br><a><b>"; // These tags will NOT be stripped off!
		if ($striptags) {
			$introtext = strip_tags($introtext, $allowed_tags);
			$fulltext = strip_tags($fulltext, $allowed_tags);
		}
			
		// Word limitation
		if ($srfr_fi_words) {
			$introtext = word_limiter($item->get_description(),$srfr_fi_words);
			$fulltext = word_limiter($item->get_content(),$srfr_fi_words);
		}
As you can see, the last four lines are the culprit. If word limitation is on, it calls the original content/description from the feed ($item->get_content())as opposed to the currently formatted text (i.e. $fulltext). This causes all the formatting/validations done from line 188 to be disregarded.

Fix:
There are two possible fixes,
1. rewrite the lines as
$introtext = word_limiter($introtext,$srfr_fi_words);
$fulltext = word_limiter($fulltext,$srfr_fi_words);

2. Comment out lines 190 and 191 and move the word limitation validation right below it. i.e. after the fix, the code block will read as
<?php
// Assign
//$introtext = $item->get_description();
//$fulltext = $item->get_content();

// Word limitation
if ($srfr_fi_words) {
$introtext = word_limiter($item->get_description(),$srfr_fi_words);
$fulltext = word_limiter($item->get_content(),$srfr_fi_words);
}

// Remove images
if ($srfr_fi_hideimages) {
$introtext = preg_replace("/<img.+?>/", "", $introtext);
$fulltext = preg_replace("/<img.+?>/", "", $fulltext);
}

// HTML cleanup
$allowed_tags = "<img><p><br><a><b>"; // These tags will NOT be stripped off!
if ($striptags) {
$introtext = strip_tags($introtext, $allowed_tags);
$fulltext = strip_tags($fulltext, $allowed_tags);
}

I went for the second one simply because its theoretically faster (not that the particular site I was working on was getting so many hits, but... ;) )

Hope this will help others.

Please Log in or Create an account to join the conversation.

More
14 years 7 months ago #22767 by ty_buchanan
RSS Feedreader PHP has stopped working on my site, though script still works.  Also Include PHP works.  So there is nothing wrong with my server's PHP set up.

Though the RSS Feedreader site gives,

<?php
$olderror_reporting =error_reporting(0);
include ("rssfeedreader.com/rss3/rss.php?url=http%3A%2F%2Fwww.goldcoast.com.au%2Frss%2Feditorial-news.xml&newpage=1&chead=1&atl=1&desc=1&owncss=&eleminate=&auth=1&dts=1&width=900&max=10&tlen=0&rnd=1&bt=3&bs=Double&nmb=&ntb=&naf=&nst=&nwd=900&nht=0&dlen=0&lstyle=-1&lc=Blue&bg=White&bc=Gray&spc=&ims=&tc=&ts=11&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS.$HTTP_SERVER_VARS."&phpout=1");
error_reporting($olderror_reporting);
?>
We know that you have to leave out line2 and the second last line:
<?php
include ("rssfeedreader.com/rss3/rss.php?url=http%3A%2F%2Fwww.goldcoast.com.au%2Frss%2Feditorial-news.xml&newpage=1&chead=1&atl=1&desc=1&owncss=&eleminate=&auth=1&dts=1&width=900&max=10&tlen=0&rnd=1&bt=3&bs=Double&nmb=&ntb=&naf=&nst=&nwd=900&nht=0&dlen=0&lstyle=-1&lc=Blue&bg=White&bc=Gray&spc=&ims=&tc=&ts=11&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS.$HTTP_SERVER_VARS."&phpout=1");
?>
But it still won't work.  Any ideas?  Ty

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #22768 by therealkw15
The fix outlined in the first message worked great for me, thanks. Much appreciated.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum