1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

RSS validation fixes.

This commit is contained in:
Cameron
2015-06-17 11:26:14 -07:00
parent 95e645d7d1
commit 1e174e2169
3 changed files with 27 additions and 12 deletions

View File

@@ -1955,20 +1955,24 @@ class e_parse extends e_parser
* @param boolean $tags [optional] * @param boolean $tags [optional]
* @return string * @return string
*/ */
function toRss($text, $tags = FALSE) function toRss($text, $tags = false)
{ {
if($tags != TRUE) if($tags != true)
{ {
$text = $this -> toHTML($text, TRUE); $text = $this -> toHTML($text, true);
$text = strip_tags($text); $text = strip_tags($text);
} }
$text = $this->toEmail($text); $text = $this->toEmail($text);
$search = array("'", "$", "'", "$"," & ", e_BASE, "href='request.php"); $search = array("'", "$", "'", "$", e_BASE, "href='request.php");
$replace = array("'", '$', "'", '$',' & ', SITEURL, "href='".SITEURL."request.php" ); $replace = array("'", '$', "'", '$', SITEURL, "href='".SITEURL."request.php" );
$text = str_replace($search, $replace, $text); $text = str_replace($search, $replace, $text);
if($tags == TRUE && ($text)) // Fix any left-over '&'
$text = str_replace('&', '&', $text); //first revert any previously converted.
$text = str_replace('&', '&', $text);
if($tags == true && ($text))
{ {
$text = "<![CDATA[".$text."]]>"; $text = "<![CDATA[".$text."]]>";
} }
@@ -3451,6 +3455,10 @@ TMPL;
echo "<h3>User-input &gg; toEmail(\$text) <small>from DB</small></h3>"; echo "<h3>User-input &gg; toEmail(\$text) <small>from DB</small></h3>";
print_a($toEmail); print_a($toEmail);
// toEmail
$toRss = $tp->toRss($text);
echo "<h3>User-input &gg; toRss(\$text)</h3>";
print_a($toRss);
echo "</div>"; echo "</div>";

View File

@@ -100,7 +100,7 @@ class news_rss // plugin-folder + '_rss'
$rss[$i]['author_email'] = $value['user_email']; $rss[$i]['author_email'] = $value['user_email'];
$rss[$i]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs'); $rss[$i]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs');
$rss[$i]['category_link'] = SITEURL."news.php?cat.".$value['news_category']; //TODO SEFURL. $rss[$i]['category_link'] = SITEURL."news.php?cat.".$value['news_category']; //TODO SEFURL.
$rss[$i]['pubdate'] = $value['news_datestamp']; $rss[$i]['datestamp'] = $value['news_datestamp'];
$rss[$i]['description'] = $this->getDescription($value); $rss[$i]['description'] = $this->getDescription($value);
if($value['news_allow_comments'] && $pref['comments_disabled'] != 1) if($value['news_allow_comments'] && $pref['comments_disabled'] != 1)

View File

@@ -324,6 +324,7 @@ class rssCreate
$this -> rssItems[$k]['author'] = $row['author']; $this -> rssItems[$k]['author'] = $row['author'];
$this -> rssItems[$k]['author_email'] = $row['author_email']; $this -> rssItems[$k]['author_email'] = $row['author_email'];
$this -> rssItems[$k]['title'] = $row['title']; $this -> rssItems[$k]['title'] = $row['title'];
if($row['link']) if($row['link'])
{ {
if(stripos($row['link'], 'http') !== FALSE) if(stripos($row['link'], 'http') !== FALSE)
@@ -366,10 +367,14 @@ class rssCreate
$this -> rssItems[$k]['category_link'] = SITEURLBASE.e_PLUGIN_ABS.$row['category_link']; $this -> rssItems[$k]['category_link'] = SITEURLBASE.e_PLUGIN_ABS.$row['category_link'];
} }
} }
if($row['datestamp']) if(!empty($row['datestamp']))
{ {
$this -> rssItems[$k]['pubdate'] = $row['datestamp']; $this -> rssItems[$k]['pubdate'] = $row['datestamp'];
} }
else
{
$this -> rssItems[$k]['pubdate'] = time();
}
if($row['custom']) if($row['custom'])
{ {
@@ -472,8 +477,10 @@ class rssCreate
<generator>e107 (http://e107.org)</generator> <generator>e107 (http://e107.org)</generator>
<sy:updatePeriod>hourly</sy:updatePeriod> <sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency> <sy:updateFrequency>1</sy:updateFrequency>
<ttl>60</ttl> <ttl>60</ttl>";
<atom:link href=\"".e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'id'=>$this->topicid),'full')."\" rel=\"self\" type=\"application/rss+xml\" />\n";
echo "
<atom:link href=\"".$tp->toRss(e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'rss_topicid'=>$this->topicid),'full'))."\" rel=\"self\" type=\"application/rss+xml\" />\n";
if (trim(SITEBUTTON)) if (trim(SITEBUTTON))
{ {
@@ -654,7 +661,7 @@ class rssCreate
echo " echo "
<uri>http://e107.org/</uri>\n <uri>http://e107.org/</uri>\n
</author>\n </author>\n
<link rel='self' href='".e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'id'=>$this->topicid),'full')."' />\n"; <link rel='self' href='".$tp->toRss(e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'rss_topicid'=>$this->topicid),'full'))."' />\n";
// Optional // Optional
include(e_ADMIN."ver.php"); include(e_ADMIN."ver.php");
@@ -694,7 +701,7 @@ class rssCreate
//<content>complete story here</content>\n //<content>complete story here</content>\n
echo " echo "
<link rel='alternate' type='text/html' href='".$value['link']."' />\n <link rel='alternate' type='text/html' href='".$value['link']."' />\n
<summary type='text'>".$tp->toRss($value['description']). "</summary>\n"; <summary type='text'>".$tp->toRss($tp->toText($value['description'])). "</summary>\n";
// Optional // Optional
if(!empty($value['category_name'])) if(!empty($value['category_name']))