On a Drupal 7 site with Flickr 7.x-1.6, we are getting the following errors:
Warning: getimagesize(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in theme_flickr_photo() (line 364 of /var/www/drupal-7.31/sites/all/modules/flickr/flickr.module).
Warning: getimagesize(https://farm4.static.flickr.com/3895/15031934137_ede4836a85.jpg): failed to open stream: no suitable wrapper could be found in theme_flickr_photo() (line 364 of /var/www/drupal-7.31/sites/all/modules/flickr/flickr.module).
Is this a server configuration thing? Isn't enabling allow_url_fopen insecure?
I see a similar report for the Locale module, which we do not have enabled:
https://www.drupal.org/node/1814980
I also see a similar report about http vs https in the flickr module, but all of the code in 7.x-1.6 seems to already have https.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | Flickr settings - demo_flickr.png | 17.43 KB | lolandese |
| #8 | use_curl_to_grab_image_width-2361813-8.patch | 4.09 KB | lolandese |
| #6 | use_curl_to_grab_image_width-2361813-6.patch | 3.96 KB | lolandese |
Comments
Comment #1
lolandese commentedThere is a never committed patch here. It makes use of cURL instead of fopen. If it doesn't apply cleanly, do it manually (and reroll).
If it works we could do some sort of detection if fopen of curl is used and act on that.
Thanks for reporting.
Comment #2
memcinto commentedThis worked -- my version of the module didn't have any getimagesize code in the flickrfield.module, so I manually edited the flickr.module file and added the ranger function and changed the one instance of getimagesize.
Comment #3
lolandese commentedIt is good to know that patch would solve your issue. Thanks for testing it.
getimagesize is a PHP image function that seems to work only if "allow_url_fopen" is turned on (allow_url_fopen = On usually found in the php.ini file).
But what if you or your host company have turned it off over a security concern? Well storing the file locally, as suggested by the linked article, wouldn't be an option, as possibly we want to avoid copyright issues by using the remote file directly. That leaves only the use of cURL as an alternative for fopen (read getimagesize ).
By the way, it has to be said in this context that the use of getimagesize in itself is not insecure. Someone even suggests to use it to get reliable data (not spoofed) about an image file (maybe a better way). Furthermore fopen is not used directly as a function anywhere in the Flickr module's code. It can therefore not be used to inject malicious code. Anyway, we can be pretty sure that any files with the .jpg extension on the https://farm.staticflickr.com domain are in fact images (can we?). Web hosts that turn "allow_url_fopen" off, do it only as a precaution to avoid their clients inadvertently use software with insecure code (non-sanitized user-provided data used by several fopen related functions).
It's nice to see I can reuse some code that was not necessary for the issue the patch was posted on. What to do next?
It might be a good idea to give an option to choose between getimagesize (fopen dependent) and our cURL based custom script (the ranger function) on the Flickr module configuration page in case both are available.
I'll see what I can do over the weekend to re-roll the patch for the latest Git version and maybe add some fopen/curl detection script and settings.
Thanks again.
Comment #4
lolandese commentedComment #5
lolandese commentedComment #6
lolandese commentedAttached patch:
We are uncertain if cURL is faster than the native 'getimagesize' PHP function in the latest versions of PHP. Some sources mention this, e.g. http://roldanarts.com/2009/11/18/diego-roldan/blog/curl-vs-getimagesize-....
Comment #7
lolandese commentedMentioned in the issue description.
Comment #8
lolandese commentedIt is better to be more specific on the configuration page that the cURL option is visible based on detected server configuration. If not, someone managing the Flickr module on different servers might wonder why he has the option available on one server and not on the other. See attached screenshot.
Comment #9
lolandese commented