WP_HTTP: ensure that the temporary file is created within the temporary directly when stream
is specified without a filename
parameter.
Fixes #32549 git-svn-id: https://develop.svn.wordpress.org/trunk@32712 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9f13e05b64
commit
306d8b6a1e
@ -213,7 +213,7 @@ class WP_Http {
|
||||
* and pick its name using the basename of the $url.
|
||||
*/
|
||||
if ( $r['stream'] && empty( $r['filename'] ) ) {
|
||||
$r['filename'] = wp_unique_filename( get_temp_dir(), basename( $url ) );
|
||||
$r['filename'] = get_temp_dir() . wp_unique_filename( get_temp_dir(), basename( $url ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -188,12 +188,13 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
|
||||
if ( ! is_wp_error( $res ) ) {
|
||||
$filesize = filesize( $res['filename'] );
|
||||
unlink( $res['filename'] );
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertFalse( is_wp_error( $res ) );
|
||||
$this->assertEquals( '', $res['body'] ); // The body should be empty.
|
||||
$this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..)
|
||||
$this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters
|
||||
$this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp dir
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user