[GH-ISSUE #486] Redirect URLs without protocol schema are not handled correctly #175

Closed
opened 2026-02-25 22:34:32 +03:00 by kerem · 6 comments
Owner

Originally created by @ebner on GitHub (Aug 21, 2024).
Original GitHub issue: https://github.com/flyimg/flyimg/issues/486

Originally assigned to: @sadok-f on GitHub.

When requesting an image URL that redirects using 30x and a Location header without protocol, the redirect is not followed and the picture therefore not processed.

The problem can be observed by accessing this example URL: https://demo.flyimg.io/upload/w_120,h_90,c_1/https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image

The server replies with HTTP status 302 and Location "//images.ctfassets.net/ds6dz7ilx8up/1rbDbGZ5YXzZtOM4fwSjZu/df7de5e0f98e354fe7728bd12f55142b/callinaz-small.png?fit=pad&w=1000&h=1000"

The redirect should be followed by adding the missing protocol part before trying to fetch the data from the new location.

Originally created by @ebner on GitHub (Aug 21, 2024). Original GitHub issue: https://github.com/flyimg/flyimg/issues/486 Originally assigned to: @sadok-f on GitHub. When requesting an image URL that redirects using 30x and a Location header without protocol, the redirect is not followed and the picture therefore not processed. The problem can be observed by accessing this example URL: https://demo.flyimg.io/upload/w_120,h_90,c_1/https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image The server replies with HTTP status 302 and Location "//images.ctfassets.net/ds6dz7ilx8up/1rbDbGZ5YXzZtOM4fwSjZu/df7de5e0f98e354fe7728bd12f55142b/callinaz-small.png?fit=pad&w=1000&h=1000" The redirect should be followed by adding the missing protocol part before trying to fetch the data from the new location.
kerem 2026-02-25 22:34:32 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sadok-f commented on GitHub (Aug 26, 2024):

Thank you @ebner for opening this issue.
I'll check it out asap.

<!-- gh-comment-id:2310092733 --> @sadok-f commented on GitHub (Aug 26, 2024): Thank you @ebner for opening this issue. I'll check it out asap.
Author
Owner

@sadok-f commented on GitHub (Aug 27, 2024):

@ebner the issue is fixed in the latest release 1.4.5
thank you for reporting it.

<!-- gh-comment-id:2312330465 --> @sadok-f commented on GitHub (Aug 27, 2024): @ebner the issue is fixed in the latest release 1.4.5 thank you for reporting it.
Author
Owner

@ebner commented on GitHub (Aug 28, 2024):

Thanks @sadok-f ! I deployed 1.4.5 to test it locally and I am receiving the following error message now when trying to load from this URL https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image:

Message: curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value 
File: /var/www/html/src/Core/Entity/Image/InputImage.php
Line: 144
Trace: #0 /var/www/html/src/Core/Entity/Image/InputImage.php(144): curl_setopt(Object(CurlHandle), 10023, 'User-Agent: Moz...')
#1 /var/www/html/src/Core/Entity/Image/InputImage.php(53): Core\Entity\Image\InputImage->saveToTemporaryFile()
#2 /var/www/html/src/Core/Handler/ImageHandler.php(99): Core\Entity\Image\InputImage->__construct(Object(Core\Entity\OptionsBag), 'https://images....')
#3 /var/www/html/src/Core/Controller/DefaultController.php(26): Core\Handler\ImageHandler->processImage('rf_1,w_150,c_1', 'https://images....')
#4 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Core\Controller\DefaultController->uploadAction('rf_1,w_150,c_1', 'https://images....')
#5 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#6 /var/www/html/vendor/silex/silex/src/Silex/Application.php(496): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#7 /var/www/html/vendor/silex/silex/src/Silex/Application.php(477): Silex\Application->handle(Object(Symfony\Component\HttpFoundation\Request))
#8 /var/www/html/web/index.php(4): Silex\Application->run()
#9 {main}

The demo instance seems to load it without problems though: https://demo.flyimg.io/upload/w_120,h_90,c_1/https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image

<!-- gh-comment-id:2315918950 --> @ebner commented on GitHub (Aug 28, 2024): Thanks @sadok-f ! I deployed 1.4.5 to test it locally and I am receiving the following error message now when trying to load from this URL https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image: ``` Message: curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value File: /var/www/html/src/Core/Entity/Image/InputImage.php Line: 144 Trace: #0 /var/www/html/src/Core/Entity/Image/InputImage.php(144): curl_setopt(Object(CurlHandle), 10023, 'User-Agent: Moz...') #1 /var/www/html/src/Core/Entity/Image/InputImage.php(53): Core\Entity\Image\InputImage->saveToTemporaryFile() #2 /var/www/html/src/Core/Handler/ImageHandler.php(99): Core\Entity\Image\InputImage->__construct(Object(Core\Entity\OptionsBag), 'https://images....') #3 /var/www/html/src/Core/Controller/DefaultController.php(26): Core\Handler\ImageHandler->processImage('rf_1,w_150,c_1', 'https://images....') #4 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Core\Controller\DefaultController->uploadAction('rf_1,w_150,c_1', 'https://images....') #5 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #6 /var/www/html/vendor/silex/silex/src/Silex/Application.php(496): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /var/www/html/vendor/silex/silex/src/Silex/Application.php(477): Silex\Application->handle(Object(Symfony\Component\HttpFoundation\Request)) #8 /var/www/html/web/index.php(4): Silex\Application->run() #9 {main} ``` The demo instance seems to load it without problems though: https://demo.flyimg.io/upload/w_120,h_90,c_1/https://prs-cdp-prod-webapiproxy.azurewebsites.net/api/glt/show/270RBod2QTiO0jVCqY5Pmg/image
Author
Owner

@sadok-f commented on GitHub (Aug 28, 2024):

@ebner I think it caused by your config/parameters.yml file, since in the new version I changed the header_extra_options option from a string to an array.
if that the case, please update your file and change the option to be like:

header_extra_options: 
  - 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201'
<!-- gh-comment-id:2315932824 --> @sadok-f commented on GitHub (Aug 28, 2024): @ebner I think it caused by your config/parameters.yml file, since in the new version I changed the `header_extra_options` option from a string to an array. if that the case, please update your file and change the option to be like: ``` header_extra_options: - 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201' ```
Author
Owner

@ebner commented on GitHub (Aug 29, 2024):

You are right. It works now, thanks!

I had taken the initial configuration from here: https://github.com/flyimg/flyimg/blob/main/config/parameters.yml
In that configuration header_extra_options is active by default. I can imagine that there are a lot of configurations out there that will experience the same problem as I had.

<!-- gh-comment-id:2316740920 --> @ebner commented on GitHub (Aug 29, 2024): You are right. It works now, thanks! I had taken the initial configuration from here: https://github.com/flyimg/flyimg/blob/main/config/parameters.yml In that configuration `header_extra_options` is active by default. I can imagine that there are a lot of configurations out there that will experience the same problem as I had.
Author
Owner

@sadok-f commented on GitHub (Aug 29, 2024):

thanks for pointing this out, I'll work on a fix to prevent this from happening.

<!-- gh-comment-id:2317171681 --> @sadok-f commented on GitHub (Aug 29, 2024): thanks for pointing this out, I'll work on a fix to prevent this from happening.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flyimg#175
No description provided.