Skip to content

Use cURL over file_get_content when available - #3500

Merged
bsweeney merged 1 commit into
dompdf:masterfrom
Starfox64:patch-2
Jun 29, 2025
Merged

Use cURL over file_get_content when available#3500
bsweeney merged 1 commit into
dompdf:masterfrom
Starfox64:patch-2

Conversation

@Starfox64

Copy link
Copy Markdown
Contributor

Dompdf will always use file_get_content as long as allow_url_fopen is enabled (which it is by default).
This unfortunately means that cURL will essentially never be used and we are stuck with file_get_contents and it's limitations:

I think usage of cURL should have priority over file_get_contents as it's more robust.

I considered making this configurable but since this method is static and doesn't have access to configuration, this becomes difficult.

@bsweeney

bsweeney commented Jul 24, 2024

Copy link
Copy Markdown
Member

follow_location does not work under certain circumstances

Under what circumstances? Follow location is disabled by default. When enabled, under what circumstances does it not work with file_get_contents?

Helpers::encodeURI still corrupts some characters (@ symbol)

Do you have a sample URL?

@Starfox64

Copy link
Copy Markdown
Contributor Author

@bsweeney bsweeney added this to the 3.0.1 milestone Jul 24, 2024
@bsweeney

Copy link
Copy Markdown
Member

Thanks for the info. The change seems fine on first look. I'll let you know if I have any feedback once I have a chance to mull it over.

@bsweeney bsweeney modified the milestones: 3.0.1, 3.0.2 Dec 2, 2024
@bsweeney

bsweeney commented May 25, 2025

Copy link
Copy Markdown
Member

I don't think the issue is with Helpers::encodeURI. When I run that sample URL through the method it returns without any changes (in the latest release). Using the URL in an image src attribute shows correct handling internally as far as I can tell. file_get_content handling could be problematic, but I don't have a valid Google Storage URL I can use for testing.

@Starfox64

Copy link
Copy Markdown
Contributor Author

I'll give this another try in the coming weeks to verify, currently unavailable.

@bsweeney

bsweeney commented Jun 1, 2025

Copy link
Copy Markdown
Member

FYI while I'd like to confirm the issues with the in-built logic, I'll move forward with the change regardless since curl is generally more robust.

@bsweeney

Copy link
Copy Markdown
Member

I did a test with the path+querystring from that sample URL using an online request inspector and it showed exactly what was expected. Possible that we've addressed whatever issues you were previously experiencing. If you find otherwise let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo