Commit 007037da authored by Malcolm Blaney's avatar Malcolm Blaney

Bug fix following last commit, SimplePie Items were not trying to

use the image cache when processing enclosures.
parent 162c6473
Pipeline #34767595 passed with stage
in 1 minute and 20 seconds
......@@ -1108,7 +1108,7 @@ class Reader extends Base {
$title = $item['title'];
$content = content_markup($item['content']);
if (count($enclosure_list['photo']) > 0) {
if (isset($enclosure_list['photo'][0])) {
$photo_list = [];
foreach ($enclosure_list['photo'] as $photo) {
if (strpos($content, $photo) === false) {
......@@ -1141,11 +1141,15 @@ class Reader extends Base {
$content .= '<p><img src="' . $photo_list[0] . '"></p>';
}
}
foreach ($enclosure_list['audio'] as $audio) {
$content .= '<audio controls src="' . $audio . '"></audio>';
if (isset($enclosure_list['audio'][0])) {
foreach ($enclosure_list['audio'] as $audio) {
$content .= '<audio controls src="' . $audio . '"></audio>';
}
}
foreach ($enclosure_list['video'] as $video) {
$content .= '<video controls src="' . $video . '"></video>';
if (isset($enclosure_list['video'][0])) {
foreach ($enclosure_list['video'] as $video) {
$content .= '<video controls src="' . $video . '"></video>';
}
}
$date = date('j F g:ia', $item['timestamp']);
$reader_format = $title === '' || $config['hide-titles'] ?
......@@ -1158,8 +1162,10 @@ class Reader extends Base {
$author .= '<a href="' . $author_url . '" class="author-name">' .
$author_name . '</a>';
$category = '';
foreach ($category_list as $tag) {
$category .= category_markup($tag);
if (isset($category_list[0])) {
foreach ($category_list as $tag) {
$category .= category_markup($tag);
}
}
if ($category !== '') {
$category = '<span class="reader-tag-label">tags: </span>' . $category;
......
......@@ -172,11 +172,12 @@ class SimplePie_Item
* @param string $data Data to sanitize
* @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
* @param string $base Base URL to resolve URLs against
* @param bool $try_cache Set to true to try using image cache
* @return string Sanitized data
*/
public function sanitize($data, $type, $base = '')
public function sanitize($data, $type, $base = '', $try_cache = false)
{
return $this->feed->sanitize($data, $type, $base);
return $this->feed->sanitize($data, $type, $base, $try_cache);
}
/**
......@@ -637,7 +638,7 @@ class SimplePie_Item
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
{
$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]), true);
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
{
......@@ -659,7 +660,7 @@ class SimplePie_Item
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
{
$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]), true);
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
{
......@@ -1665,7 +1666,7 @@ class SimplePie_Item
{
if (isset($thumbnail['attribs']['']['url']))
{
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
}
}
......@@ -1675,7 +1676,7 @@ class SimplePie_Item
{
if (isset($thumbnail['attribs']['']['url']))
{
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
}
}
......@@ -1822,7 +1823,7 @@ class SimplePie_Item
{
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
......@@ -2311,7 +2312,7 @@ class SimplePie_Item
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
if (is_array($thumbnails))
{
......@@ -2322,7 +2323,7 @@ class SimplePie_Item
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
if (is_array($thumbnails))
{
......@@ -2446,7 +2447,7 @@ class SimplePie_Item
}
if (isset($content['attribs']['']['url']))
{
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
......@@ -2736,7 +2737,7 @@ class SimplePie_Item
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
if (isset($thumbnail['attribs']['']['url'])) {
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, '', true);
}
}
if (is_array($thumbnails))
......@@ -2827,7 +2828,7 @@ class SimplePie_Item
$url = null;
$width = null;
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link), true);
if (isset($link['attribs']['']['type']))
{
$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
......@@ -2862,7 +2863,7 @@ class SimplePie_Item
$url = null;
$width = null;
$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]), true);
if (isset($enclosure[0]['attribs']['']['type']))
{
$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment