Changeset 45135
- Timestamp:
- 04/08/2019 05:31:35 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r44397 r45135 450 450 foreach ( $cookies as $name => $value ) { 451 451 if ( $value instanceof WP_Http_Cookie ) { 452 $cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes() );452 $cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes(), array( 'host-only' => $value->host_only ) ); 453 453 } elseif ( is_scalar( $value ) ) { 454 454 $cookie_jar[ $name ] = new Requests_Cookie( $name, $value ); -
trunk/src/wp-includes/class-wp-http-cookie.php
r42343 r45135 62 62 63 63 /** 64 * host-only flag. 65 * 66 * @since 5.2.0 67 * @var bool 68 */ 69 public $host_only; 70 71 /** 64 72 * Sets up this cookie object. 65 73 * … … 68 76 * 69 77 * @since 2.8.0 78 * @since 5.2.0 Added `host_only` to the `$data` parameter. 70 79 * 71 80 * @param string|array $data { 72 81 * Raw cookie data as header string or data array. 73 82 * 74 * @type string $name Cookie name. 75 * @type mixed $value Value. Should NOT already be urlencoded. 76 * @type string|int $expires Optional. Unix timestamp or formatted date. Default null. 77 * @type string $path Optional. Path. Default '/'. 78 * @type string $domain Optional. Domain. Default host of parsed $requested_url. 79 * @type int $port Optional. Port. Default null. 83 * @type string $name Cookie name. 84 * @type mixed $value Value. Should NOT already be urlencoded. 85 * @type string|int $expires Optional. Unix timestamp or formatted date. Default null. 86 * @type string $path Optional. Path. Default '/'. 87 * @type string $domain Optional. Domain. Default host of parsed $requested_url. 88 * @type int $port Optional. Port. Default null. 89 * @type bool $host_only Optional. host-only storage flag. Default true. 80 90 * } 81 91 * @param string $requested_url The URL which the cookie was set on, used for default $domain … … 129 139 130 140 // Set properties based directly on parameters. 131 foreach ( array( 'name', 'value', 'path', 'domain', 'port' ) as $field ) {141 foreach ( array( 'name', 'value', 'path', 'domain', 'port', 'host_only' ) as $field ) { 132 142 if ( isset( $data[ $field ] ) ) { 133 143 $this->$field = $data[ $field ]; -
trunk/src/wp-includes/class-wp-http-requests-response.php
r42343 r45135 165 165 $cookies[] = new WP_Http_Cookie( 166 166 array( 167 'name' => $cookie->name, 168 'value' => urldecode( $cookie->value ), 169 'expires' => isset( $cookie->attributes['expires'] ) ? $cookie->attributes['expires'] : null, 170 'path' => isset( $cookie->attributes['path'] ) ? $cookie->attributes['path'] : null, 171 'domain' => isset( $cookie->attributes['domain'] ) ? $cookie->attributes['domain'] : null, 167 'name' => $cookie->name, 168 'value' => urldecode( $cookie->value ), 169 'expires' => isset( $cookie->attributes['expires'] ) ? $cookie->attributes['expires'] : null, 170 'path' => isset( $cookie->attributes['path'] ) ? $cookie->attributes['path'] : null, 171 'domain' => isset( $cookie->attributes['domain'] ) ? $cookie->attributes['domain'] : null, 172 'host_only' => isset( $cookie->flags['host-only'] ) ? $cookie->flags['host-only'] : null, 172 173 ) 173 174 ); -
trunk/tests/phpunit/tests/http/functions.php
r43571 r45135 200 200 $this->assertSame( 'foo', $cookie->value ); 201 201 } 202 203 /** 204 * @ticket 43231 205 */ 206 function test_get_cookie_host_only() { 207 // emulate WP_Http::request() internals 208 $requests_response = new Requests_Response(); 209 210 $requests_response->cookies['test'] = Requests_Cookie::parse( 'test=foo; domain=.wordpress.org' ); 211 212 $requests_response->cookies['test']->flags['host-only'] = false; // https://github.com/rmccue/Requests/issues/306 213 214 $http_response = new WP_HTTP_Requests_Response( $requests_response ); 215 216 $response = $http_response->to_array(); 217 218 // check the host_only flag in the resulting WP_Http_Cookie 219 $cookie = wp_remote_retrieve_cookie( $response, 'test' ); 220 $this->assertEquals( $cookie->domain, 'wordpress.org' ); 221 $this->assertFalse( $cookie->host_only, 'host-only flag not set' ); 222 223 // regurgitate (Requests_Cookie -> WP_Http_Cookie -> Requests_Cookie) 224 $cookies = WP_Http::normalize_cookies( wp_remote_retrieve_cookies( $response ) ); 225 $this->assertFalse( $cookies['test']->flags['host-only'], 'host-only flag data lost' ); 226 } 202 227 }
Note: See TracChangeset
for help on using the changeset viewer.