Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Dumke on December 20, 2017, 05:51:31 AM

Title: Image Proxy Redirect issue, after patch.
Post by: Dumke on December 20, 2017, 05:51:31 AM
Hi,

I'm still experiencing the https image redirect issue with sites that are posted as http but redirect to https on parse
such as imgur and tinypic.

I have the latest updates for SMF.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Aleksi "Lex" Kilpinen on December 21, 2017, 12:35:48 PM
I'm sorry, I'm a bit out of touch - what issue exactly is this? What is happening?
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Illori on December 21, 2017, 12:45:02 PM
maybe related to https://www.simplemachines.org/community/index.php?topic=553901.0 this is reported to have been fixed in 2.0.15 though.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Dumke on December 22, 2017, 04:47:38 AM
It's exactly as Illori suggests.

It sporatically works across my site.
some specific sites work and sometimes don't.
sometimes deviantart url's are correctly proxied, sometimes they 404.
same happens with tinyurl, tumblr, tinypic, various wikia pages, imgur still occasionally does it.

The images that don't work on my site, nor display, however they work here after 2-3 refreshes.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Aleksi "Lex" Kilpinen on December 22, 2017, 01:09:55 PM
The images that don't work on my site, nor display, however they work here after 2-3 refreshes.
Out of curiosity, and to try diagnose this further - could you post some example photos here?
I might be tempted to try them on a couple of forums I run too, to see if I can get similar results.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Shambles on December 22, 2017, 06:33:15 PM
@Dumke

Look at lines 192 - 197 in your file proxy.php

Does it look like this?

Code: (check) [Select]
return file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
))) === false ? 1 : null;;

If so, change it to look like this:

Code: (replace) [Select]
return (file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
)))) === false ? false : true;

References:

https://www.simplemachines.org/community/index.php?topic=553914
https://www.simplemachines.org/community/index.php?topic=557511.msg3950735#msg3950735
Title: Re: Image Proxy Redirect issue, after patch.
Post by: tjbalon on December 22, 2017, 10:39:21 PM
Having this issue as well..

Any website with existing SSL on it, if you attempt to link the non-HTTPs version but the website has a 301 redirect for the https version, it will not work.

Bug report ref: https://www.simplemachines.org/community/index.php?topic=557878.0
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Tw2Stefan on December 23, 2017, 01:12:40 AM
@Dumke

Look at lines 192 - 197 in your file proxy.php

Does it look like this?

Code: (check) [Select]
return file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
))) === false ? 1 : null;;

If so, change it to look like this:

Code: (replace) [Select]
return (file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
)))) === false ? false : true;

References:

https://www.simplemachines.org/community/index.php?topic=553914
https://www.simplemachines.org/community/index.php?topic=557511.msg3950735#msg3950735

Wasn't this fix included in 2.0.15?
Regardless, this does not resolve the issue that tjbalon has highlighted with some images not appearing when appended with http instead of https.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Aleksi "Lex" Kilpinen on December 23, 2017, 04:59:52 AM
Wasn't this fix included in 2.0.15?
AFAIK, that should be fixed in 2.0.15

Bug report ref: https://www.simplemachines.org/community/index.php?topic=557878.0
Thanks. :)
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Shambles on December 23, 2017, 07:29:19 AM
Quote from: Aleksi "Lex" Kilpinen
AFAIK, that should be fixed in 2.0.15

No, the "fix" was incorrectly coded as confirmed by one of the devs in one of the links I posted.

Make the code change I displayed and then test it.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Dumke on December 23, 2017, 11:07:23 AM
@Dumke

Look at lines 192 - 197 in your file proxy.php

Does it look like this?

Code: (check) [Select]
return file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
))) === false ? 1 : null;;

If so, change it to look like this:

Code: (replace) [Select]
return (file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
)))) === false ? false : true;

References:

https://www.simplemachines.org/community/index.php?topic=553914
https://www.simplemachines.org/community/index.php?topic=557511.msg3950735#msg3950735
Sorry for the slow response. Holiday season.

Thank you very much for your reply,
That fixes alot of issues, however alot still doesn't entirely work.

The images that don't work on my site, nor display, however they work here after 2-3 refreshes.
Out of curiosity, and to try diagnose this further - could you post some example photos here?
I might be tempted to try them on a couple of forums I run too, to see if I can get similar results.

example, works here, but not on my site.

http://media.discordapp.net/attachments/163960689352900609/394091264251002880/image.jpg

http://vignette.wikia.nocookie.net/yakuza-mob-roleplay/images/5/5e/Tumblr_n1kkxeLnyw1raiwcso1_500.gif - displays, but still 404's interesting enough.

Having this issue as well..

Any website with existing SSL on it, if you attempt to link the non-HTTPs version but the website has a 301 redirect for the https version, it will not work.

Bug report ref: https://www.simplemachines.org/community/index.php?topic=557878.0

Yes, exactly this, but out of curiosity, i tried your two example images myself, after applying @sǝๅqɯɐɥS's fix,

"csgo.png" 404's and fails to proxy, however your "bg.png" proxies just fine.

Title: Re: Image Proxy Redirect issue, after patch.
Post by: Aleksi "Lex" Kilpinen on December 23, 2017, 11:15:19 AM
The images that don't work on my site, nor display, however they work here after 2-3 refreshes.
Out of curiosity, and to try diagnose this further - could you post some example photos here?
I might be tempted to try them on a couple of forums I run too, to see if I can get similar results.
example, works here, but not on my site.

http://media.discordapp.net/attachments/163960689352900609/394091264251002880/image.jpg

http://vignette.wikia.nocookie.net/yakuza-mob-roleplay/images/5/5e/Tumblr_n1kkxeLnyw1raiwcso1_500.gif - displays, but still 404's interesting enough.
OK thanks, That is interesting.
Both of those worked fine on my own forums, though only after 1 refresh. Not on the first display.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Dumke on December 23, 2017, 11:21:15 AM
OK thanks, That is interesting.
Both of those worked fine on my own forums, though only after 1 refresh. Not on the first display.

If you check the console do any of them display 404 error?
that's the same interaction i get here, doesn't work first load, works second, with 404 error displayed in console.

edit: on attempt two, they cleanly proxy.

edit2: on attempt three, (the interaction purely with this site) with a different image from the same source as the other wikia link, it will fail to load first, 404 on the second load but display, third cleanly proxies no 404.
Title: Re: Image Proxy Redirect issue, after patch.
Post by: Aleksi "Lex" Kilpinen on January 08, 2018, 05:10:44 AM
Similar case in Bug Reports: Proxying images SMF 2.0.15 (https://www.simplemachines.org/community/index.php?topic=557511.0)