From 86744c9a4b3ba592138910b92f01fc7b0b45b042 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 16 May 2009 02:17:55 +0000 Subject: [PATCH] Support headers split over multiple lines. Props hakre, Denis-de-Bernardy, wnorris. fixes #9395 git-svn-id: https://develop.svn.wordpress.org/trunk@11351 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/http.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index e292bfcb35..e3575f2c09 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -396,8 +396,15 @@ class WP_Http { * Then a numbered array is returned as the value of that header-key. */ function processHeaders($headers) { - if ( is_string($headers) ) - $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) ); + // split headers, one per array element + if ( is_string($headers) ) { + // tolerate line terminator: CRLF = LF (RFC 2616 19.3) + $headers = str_replace("\r\n", "\n"); + // unfold folded header fields. LWS = [CRLF] 1*( SP | HT ) , (RFC 2616 2.2) + $headers = preg_replace('/\n[ \t]/', ' ', $headers); + // create the headers array + $headers = explode("\n", $headers); + } $response = array('code' => 0, 'message' => '');