diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index fac3e55..0758d96 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -1,9 +1,4 @@ xml_encode($_SERVER['REQUEST_URI']); $extraInfos = $this->getExtraInfos(); - $title = xml_encode($extraInfos['name']); + $title = $this->xml_encode($extraInfos['name']); $uri = $extraInfos['uri']; - $icon = xml_encode('http://icons.better-idea.org/icon?url='. $uri .'&size=64'); - $uri = xml_encode($uri); + $icon = $this->xml_encode('http://icons.better-idea.org/icon?url='. $uri .'&size=64'); + $uri = $this->xml_encode($uri); $entries = ''; foreach($this->getDatas() as $data){ - $entryAuthor = is_null($data->author) ? $title : xml_encode($data->author); - $entryTitle = is_null($data->title) ? '' : xml_encode($data->title); - $entryUri = is_null($data->uri) ? '' : xml_encode($data->uri); - $entryTimestamp = is_null($data->timestamp) ? '' : xml_encode(date(DATE_ATOM, $data->timestamp)); + $entryAuthor = is_null($data->author) ? $title : $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)); // We prevent content from closing the CDATA too early. $entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>'; @@ -96,4 +91,8 @@ EOD; return parent::display(); } + + private function xml_encode($text) { + return htmlspecialchars($text, ENT_XML1); + } }