About af_zz_imgproxy (Load insecure images via built-in proxy)

Post plugins and custom CSS snippets here
Exagone313
Bear Rating Trainee
Bear Rating Trainee
Posts: 6
Joined: 06 Jan 2016, 14:38

About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby Exagone313 » 12 Feb 2017, 15:28

Hi,

This message is more for fox but I think it's better to send in public.
This plugin is nice, but has one missing ability, maybe it will be added later as it's really new: it does not proxy images in attachments (div.cdmIntermediate).
It requires to add a new hook to be used in classes/feeds.php around lines 717-722.
As I don't know the code, I would probably forget something if I edit tt-rss and the plugin, but with a bit more information, I would be ok to help (but most of the work is done anyway).

Thanks for reading this.

User avatar
fox
^ me reading your posts ^
Posts: 6269
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby fox » 12 Feb 2017, 15:52

i don't think i have any feeds like that, can you post an example?

e: i think it's PluginHost::HOOK_RENDER_ENCLOSURE although maybe it would be worth it to add a hook for enclosure urls only

e2: no idea if this works https://tt-rss.org/gitlab/fox/tt-rss/co ... d57a0c7cd7

Exagone313
Bear Rating Trainee
Bear Rating Trainee
Posts: 6
Joined: 06 Jan 2016, 14:38

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby Exagone313 » 12 Feb 2017, 16:30

Well...

Code: Select all

14:29:22.782 "Invalid object received: <br />
<b>Fatal error</b>:  Uncaught Error: Call to undefined method Af_Zz_ImgProxy::hook_render_enclosure() in /srv/http/elou.world/documentroot/tt-rss/include/functions2.php:1948
Stack trace:
#0 /srv/http/elou.world/documentroot/tt-rss/classes/feeds.php(720): format_article_enclosures('2445', false, '&lt;p&gt;Millions of ...', false)
#1 /srv/http/elou.world/documentroot/tt-rss/classes/feeds.php(938): Feeds-&gt;format_headlines_list(3, '', 'adaptive', 30, true, '', 0, '', false, true, '', false)
#2 /srv/http/elou.world/documentroot/tt-rss/backend.php(123): Feeds-&gt;view()
#3 {main}
  thrown in <b>/srv/http/elou.world/documentroot/tt-rss/include/functions2.php</b> on line <b>1948</b><br />
"1 tt-rss:408:29
headlines_callback2() tt-rss:408
viewfeed/_viewfeed_timeout</<.onComplete() tt-rss:344
Ajax.Request<.respondToReadyState() prototype.js:1827
Ajax.Request<.onStateChange() prototype.js:1756

(hook_render_enclosure vs hook_enclosure_entry, and maybe url vs content_url)

User avatar
fox
^ me reading your posts ^
Posts: 6269
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby fox » 12 Feb 2017, 17:02

should be better now, i think

Exagone313
Bear Rating Trainee
Bear Rating Trainee
Posts: 6
Joined: 06 Jan 2016, 14:38

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby Exagone313 » 12 Feb 2017, 17:15

Yes that works, just that in the Attachements menu we get the proxied url, but that's normal due to how you hooked that. Not a big deal.

User avatar
fox
^ me reading your posts ^
Posts: 6269
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby fox » 12 Feb 2017, 17:31

probably not the best idea because not all attachments are necessarily images

e: should be limited now similar to how embedding is done

Exagone313
Bear Rating Trainee
Bear Rating Trainee
Posts: 6
Joined: 06 Jan 2016, 14:38

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby Exagone313 » 12 Feb 2017, 19:43

Your latest commit broke it, it no longer proxies attachments.
I edited your code like this, and it works again:

Code: Select all

if (preg_match("/image/", $enc["content_type"]) || preg_match("/\.(jpe?g|png|gif|bmp)$/i", $enc["filename"]))

(content_type instead of type, allow jpeg extension, extension matches end of filename)

User avatar
fox
^ me reading your posts ^
Posts: 6269
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby fox » 12 Feb 2017, 20:22

ah right that datatype gets changed in the middle of that function

copy pasting things will be the end of me *he said while copypasting from the forums*

Exagone313
Bear Rating Trainee
Bear Rating Trainee
Posts: 6
Joined: 06 Jan 2016, 14:38

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby Exagone313 » 13 Feb 2017, 00:35

And also, extensions are at the end of filenames, so you can add $ to the regex here :P

EDIT: Oops that's more difficult, it can contains a query string! :(

EDIT2: You've forgotten the parameter $kind in hook_enclosure_entry.

EDIT3: I ended up forking and making my own improvements, to proxy every worth external content. I merged the plugin no_iframes and removed the whitelist (I show a thumbnail image for Youtube videos or [iframe to example.com]). It no longer only proxies mixed content. Will send it later.

User avatar
fox
^ me reading your posts ^
Posts: 6269
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: About af_zz_imgproxy (Load insecure images via built-in proxy)

Postby fox » 13 Feb 2017, 08:12

ah right, $kind should be fixed now.


Return to “Themes and plugins”

Who is online

Users browsing this forum: No registered users and 2 guests