diff options
Diffstat (limited to 'formats/JsonFormat.php')
-rw-r--r-- | formats/JsonFormat.php | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/formats/JsonFormat.php b/formats/JsonFormat.php index 3b2a29ab..bb9e81a2 100644 --- a/formats/JsonFormat.php +++ b/formats/JsonFormat.php @@ -25,10 +25,10 @@ class JsonFormat extends FormatAbstract public function stringify() { - $urlPrefix = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; - $urlHost = (isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : ''; - $urlPath = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : ''; - $urlRequest = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : ''; + $https = $_SERVER['HTTPS'] ?? null; + $urlPrefix = $https === 'on' ? 'https://' : 'http://'; + $urlHost = $_SERVER['HTTP_HOST'] ?? ''; + $urlRequest = $_SERVER['REQUEST_URI'] ?? ''; $extraInfos = $this->getExtraInfos(); @@ -52,7 +52,7 @@ class JsonFormat extends FormatAbstract $entryTitle = $item->getTitle(); $entryUri = $item->getURI(); $entryTimestamp = $item->getTimestamp(); - $entryContent = $item->getContent() ? $this->sanitizeHtml($item->getContent()) : ''; + $entryContent = $item->getContent() ? sanitize_html($item->getContent()) : ''; $entryEnclosures = $item->getEnclosures(); $entryCategories = $item->getCategories(); @@ -76,13 +76,13 @@ class JsonFormat extends FormatAbstract ]; } if (!empty($entryTimestamp)) { - $entry['date_modified'] = gmdate(DATE_ATOM, $entryTimestamp); + $entry['date_modified'] = gmdate(\DATE_ATOM, $entryTimestamp); } if (!empty($entryUri)) { $entry['url'] = $entryUri; } if (!empty($entryContent)) { - if ($this->isHTML($entryContent)) { + if (is_html($entryContent)) { $entry['content_html'] = $entryContent; } else { $entry['content_text'] = $entryContent; @@ -93,7 +93,7 @@ class JsonFormat extends FormatAbstract foreach ($entryEnclosures as $enclosure) { $entry['attachments'][] = [ 'url' => $enclosure, - 'mime_type' => getMimeType($enclosure) + 'mime_type' => parse_mime_type($enclosure) ]; } } @@ -121,13 +121,8 @@ class JsonFormat extends FormatAbstract * So consider this a hack. * Switch to JSON_INVALID_UTF8_IGNORE when PHP 7.2 is the latest platform requirement. */ - $json = json_encode($data, JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR); + $json = json_encode($data, \JSON_PRETTY_PRINT | \JSON_PARTIAL_OUTPUT_ON_ERROR); return $json; } - - private function isHTML($text) - { - return (strlen(strip_tags($text)) != strlen($text)); - } } |