Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect enclosure as images using file extension #3861

Merged
merged 2 commits into from
Sep 27, 2021

Conversation

Alkarex
Copy link
Member

@Alkarex Alkarex commented Sep 27, 2021

Support e.g. https://www.sciencesetavenir.fr/atom.xml , which does not include any type hint:

<link rel="enclosure" href="https://example.net/assets/img/ZZZ.jpg" title="YYY" />

Useful for #3805

@Alkarex Alkarex added this to the 1.19.0 milestone Sep 27, 2021
Support e.g. https://www.sciencesetavenir.fr/atom.xml , which does not include any type hint.

```html
<link rel="enclosure" href="https://example.net/assets/img/ZZZ.jpg" title="YYY"/>
```

Useful for FreshRSS#3805
@@ -410,7 +410,8 @@ public function loadEntries($simplePie) {
$height = $enclosure->get_height();
$width = $enclosure->get_width();
$length = $enclosure->get_length();
if ($medium === 'image' || strpos($mime, 'image') === 0 || ($mime == '' && $length == null && ($width != 0 || $height != 0))) {
if ($medium === 'image' || strpos($mime, 'image') === 0 ||
($mime == '' && $length == null && ($width != 0 || $height != 0 || preg_match('/[.](gif|jpe?g|png|svg)$/i', $elink)))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably also add WebP and that new one based on AV1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 5fd913d

Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about APNG earlier btw, and fwiw there's also BMP.

@Alkarex
Copy link
Member Author

Alkarex commented Sep 27, 2021

I forgot about APNG earlier btw, and fwiw there's also BMP.

Indeed, and several more, cf. e.g. https://developer.mozilla.org/docs/Web/Media/Formats/Image_types , but this is just a fallback for cases not providing any other type hint

@Alkarex Alkarex merged commit a473b90 into FreshRSS:edge Sep 27, 2021
@Alkarex Alkarex deleted the enclosure_sniff_extension branch September 27, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants