From 059b099436735ea4f9c2eba7024453621a8c784c Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Mon, 29 Aug 2016 19:05:10 +0200 Subject: [PATCH] [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. --- formats/AtomFormat.php | 12 ++++++------ formats/MrssFormat.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 56c36963..26badb83 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -7,7 +7,7 @@ class AtomFormat extends FormatAbstract{ public function stringify(){ /* 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'] : ''; $httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; @@ -21,11 +21,11 @@ class AtomFormat extends FormatAbstract{ $entries = ''; foreach($this->getDatas() as $data){ - $entryAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']); - $entryTitle = is_null($data['title']) ? '' : $this->xml_encode($data['title']); - $entryUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']); - $entryTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_ATOM, $data['timestamp'])); - $entryContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content'])); + $entryAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : ''; + $entryTitle = isset($data['title']) ? $this->xml_encode($data['title']) : ''; + $entryUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : ''; + $entryTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $data['timestamp'])) : ''; + $entryContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : ''; $entries .= << diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index d7cb682e..498db3b9 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -7,7 +7,7 @@ class MrssFormat extends FormatAbstract{ public function stringify(){ /* 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'] : ''; $httpInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; @@ -19,11 +19,11 @@ class MrssFormat extends FormatAbstract{ $items = ''; foreach($this->getDatas() as $data){ - $itemAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']); - $itemTitle = strip_tags(is_null($data['title']) ? '' : $this->xml_encode($data['title'])); - $itemUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']); - $itemTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_RFC2822, $data['timestamp'])); - $itemContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content'])); + $itemAuthor = isset($data['author']) ? $this->xml_encode($data['author']) : ''; + $itemTitle = strip_tags(isset($data['title']) ? $this->xml_encode($data['title']) : ''); + $itemUri = isset($data['uri']) ? $this->xml_encode($data['uri']) : ''; + $itemTimestamp = isset($data['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $data['timestamp'])) : ''; + $itemContent = isset($data['content']) ? $this->xml_encode($this->sanitizeHtml($data['content'])) : ''; $items .= <<