diff options
| author | 2023-02-09 13:57:20 +0100 | |
|---|---|---|
| committer | 2023-02-09 13:57:20 +0100 | |
| commit | 05ae1b0d2684cea4eda664c5ea1a995cb9f0c4b9 (patch) | |
| tree | 7f8bac745b5431139bec5197afc288ee694d28f5 /lib/lib_rss.php | |
| parent | b9a62a6aaacf2763c45f503ed5602ba43bedfce0 (diff) | |
XML+XPath (#5076)
* XML+XPath
#fix https://github.com/FreshRSS/FreshRSS/issues/5075
Implementation allowing to take an XML document as input using an XML parser (instead of an HTML parser for HTML+XPath)
* Remove noise from another PR
* Better MIME for XML
* And add glob *.xml for cache cleaning
* Minor syntax
* Add glob json for clean cache
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index f648d7cd2..434d0f9fb 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -365,7 +365,11 @@ function sanitizeHTML($data, string $base = '', ?int $maxLength = null): string function cleanCache(int $hours = 720): void { // N.B.: GLOB_BRACE is not available on all platforms - $files = array_merge(glob(CACHE_PATH . '/*.html', GLOB_NOSORT) ?: [], glob(CACHE_PATH . '/*.spc', GLOB_NOSORT) ?: []); + $files = array_merge( + glob(CACHE_PATH . '/*.html', GLOB_NOSORT) ?: [], + glob(CACHE_PATH . '/*.json', GLOB_NOSORT) ?: [], + glob(CACHE_PATH . '/*.spc', GLOB_NOSORT) ?: [], + glob(CACHE_PATH . '/*.xml', GLOB_NOSORT) ?: []); foreach ($files as $file) { if (substr($file, -10) === 'index.html') { continue; @@ -410,7 +414,7 @@ function enforceHttpEncoding(string $html, string $contentType = ''): string { } /** - * @param string $type {html,opml} + * @param string $type {html,json,opml,xml} * @param array<string,mixed> $attributes */ function httpGet(string $url, string $cachePath, string $type = 'html', array $attributes = []): string { @@ -439,9 +443,15 @@ function httpGet(string $url, string $cachePath, string $type = 'html', array $a $accept = '*/*;q=0.8'; switch ($type) { + case 'json': + $accept = 'application/json,application/javascript;q=0.9,text/javascript;q=0.8,*/*;q=0.7'; + break; case 'opml': $accept = 'text/x-opml,text/xml;q=0.9,application/xml;q=0.9,*/*;q=0.8'; break; + case 'xml': + $accept = 'application/xml,application/xhtml+xml,text/xml;q=0.9,*/*;q=0.8'; + break; case 'html': default: $accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; |
