[wp-trac] [WordPress Trac] #58566: WP_Http::normalize_cookies does not convert cookie names to strings

WordPress Trac noreply at wordpress.org
Sat Jun 17 14:03:26 UTC 2023


#58566: WP_Http::normalize_cookies does not convert cookie names to strings
--------------------------+-----------------------------
 Reporter:  nosilver4u    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  HTTP API      |    Version:  6.2.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 We ran into an issue where, if a cookie with an integer name is submitted
 via wp_remote_post(), it triggers a fatal error/exception in
 Requests\Cookie::__construct(). Looking at the stack trace, the cookies go
 through WP_Http::normalize_cookies(), which already casts the values to
 strings. Unfortunately, it just sends the cookie names straight through
 rather than casting the names to strings as is required by
 Requests\Cookies::__construct().

 Partial stack trace here:

 {{{
 PHP Fatal error: Uncaught WpOrg\Requests\Exception\InvalidArgument:
 WpOrg\Requests\Cookie::__construct(): Argument #1 ($name) must be of type
 string, integer given in [...]public_html/wp-
 includes/Requests/src/Exception/InvalidArgument.php:29
 Stack trace:
 #0 [...]public_html/wp-includes/Requests/src/Cookie.php(83):
 WpOrg\Requests\Exception\InvalidArgument::create(1, '$name', 'string',
 'integer')
 #1 [...]public_html/wp-includes/class-wp-http.php(472):
 WpOrg\Requests\Cookie->__construct(135370, '')
 #2 [...]public_html/wp-includes/class-wp-http.php(352):
 WP_Http::normalize_cookies(Array)
 #3 [...]public_html/wp-includes/class-wp-http.php(616):
 WP_Http->request('https://allegor...', Array)
 #4 [...]public_html/wp-includes/http.php(179):
 WP_Http->post('https://allegor...', Array)
 #5 [...]public_html/wp-content/plugins/ewww-image-
 optimizer/common.php(11271): wp_remote_post('https://allegor...', Array)
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58566>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list