mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-16 08:54:42 +02:00
refactor: general code base refactor (#2950)
* refactor * fix: bug in previous refactor * chore: exclude phpcompat sniff due to bug in phpcompat * fix: do not leak absolute paths * refactor/fix: batch extensions checking, fix DOS issue
This commit is contained in:
parent
b042412416
commit
2bbce8ebef
45 changed files with 679 additions and 827 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue