From e3c578510b96f37b8466e88329826b0c39e91f7a Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 9 Aug 2016 16:36:31 +0200 Subject: [PATCH] [AtomFormat] Change xml_encode($) to private scope --- formats/AtomFormat.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index fac3e550..0758d965 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); + } }