1
0
Fork 0
forked from blallo/rss-bridge

[formats] Fix missing element conditions

This fixes download behavior when requesting Atom/Mrss formats,
which was caused by is_null attempting to expand missing array
elements.
This commit is contained in:
logmanoriginal 2016-08-29 19:05:10 +02:00
parent 3c1706aa47
commit 059b099436
2 changed files with 12 additions and 12 deletions

View file

@ -7,7 +7,7 @@ class AtomFormat extends FormatAbstract{
public function stringify(){ public function stringify(){
/* Datas preparation */ /* Datas preparation */
$https = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '' ); $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '';
$httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; $httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
@ -21,11 +21,11 @@ class AtomFormat extends FormatAbstract{
$entries = ''; $entries = '';
foreach($this->getDatas() as $data){ foreach($this->getDatas() as $data){
$entryAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']); $entryAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : '';
$entryTitle = is_null($data['title']) ? '' : $this->xml_encode($data['title']); $entryTitle = isset($data['title']) ? $this->xml_encode($data['title']) : '';
$entryUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']); $entryUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : '';
$entryTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_ATOM, $data['timestamp'])); $entryTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $data['timestamp'])) : '';
$entryContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content'])); $entryContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : '';
$entries .= <<<EOD $entries .= <<<EOD
<entry> <entry>

View file

@ -7,7 +7,7 @@ class MrssFormat extends FormatAbstract{
public function stringify(){ public function stringify(){
/* Datas preparation */ /* Datas preparation */
$https = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '' ); $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '';
$httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; $httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
@ -19,11 +19,11 @@ class MrssFormat extends FormatAbstract{
$items = ''; $items = '';
foreach($this->getDatas() as $data){ foreach($this->getDatas() as $data){
$itemAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']); $itemAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : '';
$itemTitle = strip_tags(is_null($data['title']) ? '' : $this->xml_encode($data['title'])); $itemTitle = strip_tags(isset($data['title']) ? $this->xml_encode($data['title']) : '');
$itemUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']); $itemUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : '';
$itemTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_RFC2822, $data['timestamp'])); $itemTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $data['timestamp'])) : '';
$itemContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content'])); $itemContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : '';
$items .= <<<EOD $items .= <<<EOD
<item> <item>