[wp-trac] [WordPress Trac] #23915: discover_pingback_server_uri cases an error when discovery URI sets multiple Content-type headers

WordPress Trac noreply at wordpress.org
Sat Nov 9 02:54:17 UTC 2013


#23915: discover_pingback_server_uri cases an error when discovery URI sets
multiple Content-type headers
------------------------------+------------------
 Reporter:  tomdxw            |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  3.8
Component:  Pings/Trackbacks  |     Version:  2.7
 Severity:  normal            |  Resolution:
 Keywords:  needs-patch       |
------------------------------+------------------
Changes (by SergeyBiryukov):

 * keywords:   => needs-patch
 * version:  3.5.1 => 2.7
 * milestone:  Awaiting Review => 3.8


Old description:

> Line 1673 in wp-includes/comment.php uses preg_match() on the output of
> wp_remote_retrieve_header(). When multiple headers are set of the same
> name, wp_remote_retrieve_header() returns an array.
>
> Thus occasionally the following error occurs:
>
> PHP Warning: preg_match() expects parameter 2 to be string, array given
> in xxxxxxx/wp-includes/comment.php on line 1673
>
> I have no idea how to make pingbacks happen so to reproduce, add this
> line to functions.php:
> discover_pingback_server_uri('http://localhost:8080/');
>
> And in a terminal window run this (you may need to install the netcat-
> openbsd package in Debuntu): while true; do echo -en 'HTTP/1.1 200 OK\r
> \nContent-type: text/html\r\nContent-type: text/plain\r\n\r\n' | nc -lp
> 8080; done
>
> Then visit your WP installation and you shall get the aforementioned
> error message.

New description:

 Line 1673 in wp-includes/comment.php uses preg_match() on the output of
 wp_remote_retrieve_header(). When multiple headers are set of the same
 name, wp_remote_retrieve_header() returns an array.

 Thus occasionally the following error occurs:

 PHP Warning: preg_match() expects parameter 2 to be string, array given in
 xxxxxxx/wp-includes/comment.php on line 1673

 I have no idea how to make pingbacks happen so to reproduce, add this line
 to functions.php: discover_pingback_server_uri('http://localhost:8080/');

 And in a terminal window run this (you may need to install the netcat-
 openbsd package in Debuntu):
 `while true; do echo -en 'HTTP/1.1 200 OK\r\nContent-type: text/html\r
 \nContent-type: text/plain\r\n\r\n' | nc -lp 8080; done`

 Then visit your WP installation and you shall get the aforementioned error
 message.

--

Comment:

 Appears to be introduced in [9012]. Changed to use
 `wp_remote_retrieve_header()` in [17928].

 According to the inline docs, `wp_remote_retrieve_header()` always returns
 a string:
 [source:tags/3.7.1/src/wp-includes/http.php#L229]

 If it returns an array when multiple headers of the same name are set, it
 should be either fixed or noted in the docs.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/23915#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list