[wp-trac] [WordPress Trac] #60788: Content-Disposition support in download_url() seems broken
WordPress Trac
noreply at wordpress.org
Thu Aug 28 06:04:42 UTC 2025
#60788: Content-Disposition support in download_url() seems broken
--------------------------+------------------------------
Reporter: siliconforks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTTP API | Version: 6.4.3
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by pmbaldha):
== Reproduction Report
=== Description
🐞 This report validates the issue can be reproduced.
=== Environment
- WordPress: 6.8.2
- PHP: 8.2.10
- Server: Apache/2.4.43 (Win32) mod_fcgid/2.3.9a
- Database: mysqli (Server: 10.4.10-MariaDB / Client: mysqlnd 8.2.10)
- Browser: Chrome 139.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Four 1.0
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
* wpDataTables - Tables & Table Charts 6.3.3.5
=== Actual Results
1. Create echo.php file in the root folder with the following code:
{{{#!php
<?php
header( 'Content-Type: text/plain' );
header( 'Content-Disposition: attachment; filename="echo.txt"' );
if ( isset( $_GET['echo'] ) ) {
echo $_GET['echo'];
}
}}}
2. Create download.php file in the root folder with the following code:
{{{#!php
<?php
$foo = download_url( 'http://example.test/echo.php?echo=foo' );
echo file_get_contents( $foo );
echo "\n";
unlink( $foo );
$bar = download_url( 'http://example.test/echo.php?echo=bar' );
echo file_get_contents( $bar );
echo "\n";
unlink( $bar );
}}}
3. If you run this, it works as expected:
{{{
$ wp eval-file download.php
foo
bar
}}}
4. Create the download-bad.php file with the following code:
{{{#!php
<?php
$foo = download_url( 'http://example.test/echo.php?echo=foo' );
$bar = download_url( 'http://example.test/echo.php?echo=bar' );
echo file_get_contents( $foo );
echo "\n";
echo file_get_contents( $bar );
echo "\n";
unlink( $foo );
unlink( $bar );
}}}
5. 🐞 If I try to run this, the results are not good:
{{{
$ wp eval-file download-bad.php
bar
bar
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60788#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list