sanitize: properly handle cached content in archived articles
This commit is contained in:
parent
c4ebf01e69
commit
7818bfde0b
|
@ -893,23 +893,22 @@
|
||||||
$doc->loadHTML($charset_hack . $res);
|
$doc->loadHTML($charset_hack . $res);
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
|
|
||||||
$entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src])');
|
|
||||||
|
|
||||||
$ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
|
$ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
|
||||||
|
$rewrite_base_url = $site_url ? $site_url : SELF_URL_PATH;
|
||||||
|
|
||||||
|
$entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src])');
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
|
|
||||||
if ($site_url) {
|
|
||||||
|
|
||||||
if ($entry->hasAttribute('href')) {
|
if ($entry->hasAttribute('href')) {
|
||||||
$entry->setAttribute('href',
|
$entry->setAttribute('href',
|
||||||
rewrite_relative_url($site_url, $entry->getAttribute('href')));
|
rewrite_relative_url($rewrite_base_url, $entry->getAttribute('href')));
|
||||||
|
|
||||||
$entry->setAttribute('rel', 'noopener noreferrer');
|
$entry->setAttribute('rel', 'noopener noreferrer');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entry->hasAttribute('src')) {
|
if ($entry->hasAttribute('src')) {
|
||||||
$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
|
$src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src'));
|
||||||
|
|
||||||
$extension = $entry->tagName == 'source' ? '.mp4' : '.png';
|
$extension = $entry->tagName == 'source' ? '.mp4' : '.png';
|
||||||
$cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
|
$cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
|
||||||
|
@ -962,7 +961,6 @@
|
||||||
$entry->parentNode->replaceChild($p, $entry);
|
$entry->parentNode->replaceChild($p, $entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (strtolower($entry->nodeName) == "a") {
|
if (strtolower($entry->nodeName) == "a") {
|
||||||
$entry->setAttribute("target", "_blank");
|
$entry->setAttribute("target", "_blank");
|
||||||
|
|
Loading…
Reference in New Issue