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

ExternalProxy not displaying certain images. #326

Closed
mandusm opened this issue Apr 18, 2022 · 7 comments
Closed

ExternalProxy not displaying certain images. #326

mandusm opened this issue Apr 18, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@mandusm
Copy link

mandusm commented Apr 18, 2022

Describe the bug
When I have "use local proxy for images" enabled, some images do not display.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Inbox'
  2. Click on 'any email'
  3. See unloaded images.

Expected behavior
Expecting proxy to load images.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Snappy Version 2.14.3
  • All Browsers. Confirmed on Edge and Firefox.

Mobile (please complete the following information):
not tested on mobile, but since this is a php error, I am sure it will be the same.

Additional context
This is strange because images from that same domain, in the same email displays, but two of them don't. It looks like this might be a type mismatch thing. I don't think the proxy handles the png/gif redirect change very well.

Fatal error: Uncaught RuntimeException: Error 3: for http://mi.onepeloton.com/p/rp/5bb5a16e5e3a9d8d.png?mi_instructor1=Sam Yo&mi_instructor2=Bradley Rose&mi_instructor3=&mi_location=US&instructor= in /web/rainloop/snappymail/v/2.14.3/app/libraries/snappymail/http/request/curl.php:88 Stack trace: #0 /web/rainloop/snappymail/v/2.14.3/app/libraries/snappymail/http/request.php(133): SnappyMail\HTTP\Request\CURL->__doRequest('GET', 'http://mi.onepe...', NULL, Array) #1 /web/rainloop/snappymail/v/2.14.3/app/libraries/RainLoop/ServiceActions.php(355): SnappyMail\HTTP\Request->doRequest('GET', 'http://mi.onepe...') #2 /web/rainloop/snappymail/v/2.14.3/app/libraries/RainLoop/Service.php(133): RainLoop\ServiceActions->ServiceProxyExternal('') #3 /web/rainloop/snappymail/v/2.14.3/app/libraries/RainLoop/Service.php(15): RainLoop\Service::RunResult() #4 /web/rainloop/snappymail/v/2.14.3/include.php(169): RainLoop\Service::Handle() #5 /web/rainloop/index.php(11): include('/web/rainloop/s...') #6 {main} thrown in /web/rainloop/snappymail/v/2.14.3/app/libraries/snappymail/http/request/curl.php on line 88

I have been researching this issue and I believe it's related to #16

@mandusm
Copy link
Author

mandusm commented Apr 18, 2022

Ahh, okay. Looking into the code and understanding the error better.
We are reporting a CURL Error 3 here.

We are making the https://curl.se/libcurl/c/CURLINFO_RESPONSE_CODE.html call to get the response code, but because the URL is malformed, we are getting an exception 3. https://curl.se/libcurl/c/libcurl-errors.html

@the-djmaze
Copy link
Owner

  • SnappyMail Version [e.g. 2.3.4]

Could you try with 2.14.3?
https://github.com/the-djmaze/snappymail/releases/tag/v2.14.3

@mandusm
Copy link
Author

mandusm commented Apr 18, 2022

Oh, this is my fault. I missed updating the versions in the ticket.
I am on 2.14.3 and that's the version the error is appearing on.

I took a very cursory look at the code and it seems that the proxy does not strip white space in the URI.
I did a simple test to do that by adding $request_url = str_replace(' ', '%20', $request_url); to the curl request php here https://github.com/the-djmaze/snappymail/blob/master/snappymail/v/0.0.0/app/libraries/snappymail/http/request/curl.php#L23

This did fix the error I posted above, but now the redirect seems to fail at the regex check in https://github.com/the-djmaze/snappymail/blob/master/snappymail/v/0.0.0/app/libraries/snappymail/http/response.php#L81
Since the regex fails here a bit, the url which starts with // and no scheme, simply gets appended to the domain it got redirected from, and that's an invalid URL.

@mandusm
Copy link
Author

mandusm commented Apr 18, 2022

Also, Just for more clarity. The images that are trying to be resolved and failing are being redirected.

Original URL: http://mi.onepeloton.com/p/rp/5bb5a16e5e3a9d8d.png?mi_instructor1=Sam Yo&mi_instructor2=Bradley Rose&mi_instructor3=&mi_location=US&instructor

URL after White Space Replace:
http://mi.onepeloton.com/p/rp/5bb5a16e5e3a9d8d.png?mi_instructor1=Sam%20Yo&mi_instructor2=Bradley%20Rose&mi_instructor3=&mi_location=US&instructor

This returns the following relevant location header:
Location: //assets.movableink-templates.com/6909/60e3ed1a-b2b6-4065-8c9f-740771757fc8/85e4a7d2-91b8-4112-9455-a2f60cdbf0d1.gif?mi_instructor1=Sam%20Yo&mi_instructor2=Bradley%20Rose&mi_instructor3=&mi_location=US&instructor=

the-djmaze pushed a commit that referenced this issue Apr 19, 2022
@the-djmaze
Copy link
Owner

I made some changes, you can try with https://github.com/the-djmaze/snappymail/releases/tag/v2.15.0

@mandusm
Copy link
Author

mandusm commented Apr 19, 2022

Brilliant. 2.15.0 Solved this.
Thank you!

@mandusm mandusm closed this as completed Apr 19, 2022
@the-djmaze
Copy link
Owner

Your welcome!

@the-djmaze the-djmaze added the bug Something isn't working label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants