Memory issue in "is_gzipped" function

Ran into a weird issue today with the Jalponik feed and having “Cache media” selected.
Feed: Jalopnik
Article that caused issue: I'm Willing to Pay an Obscene Amount of Money For This Guy's Brilliant Pedestrian Car Horn Invention

Started seeing an error:
PHP: Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted… classes/rssutils:1554

It appears that the article included a 29MB gif and that was being passed to the mb_strpos function.
Does the full $feed_data need to be passed to this function to detect if it’s gzipped?

tt-rss version (including git commit id):
v19.8 (6060963)

Platform (i.e. Linux distro, PHP, PostgreSQL, etc) versions:
Alpine, php 7.3.11, Postgres 11

yes, but we only need to check first three bytes, so using mb_strpos() on the entire buffer was unnecessary. using the multibyte variant of strpos was not necessary either, i think.

https://git.tt-rss.org/fox/tt-rss/commit/5bb8dad63187ddd8d83d38197813596817fa7abd

e: thanks for reporting this.

Sounds reasonable to use strpos since you’re only checking for bytes and not characters. Thanks for the quick fix!

Q: regarding the PR, why not do a string compare instead of a ‘strpos’ now that you are comparing 3 bytes to 3 bytes?

yeah i thought about replacing it right after committing but figured it wasn’t worth the effort.

if you want to file a PR over this, i’ll merge it.