MDL-72349 filelib: update strip_double_headers function

This commit is contained in:
Christina Thee Roperto 2022-07-18 22:46:01 +10:00
parent d9632ca8b2
commit de07d85f23
2 changed files with 151 additions and 2 deletions

View file

@ -4201,14 +4201,14 @@ class curl {
$crlf = "\r\n";
return preg_replace(
// HTTP version and status code (ignore value of code).
'~^HTTP/1\..*' . $crlf .
'~^HTTP/[1-9](\.[0-9])?.*' . $crlf .
// Header name: character between 33 and 126 decimal, except colon.
// Colon. Header value: any character except \r and \n. CRLF.
'(?:[\x21-\x39\x3b-\x7e]+:[^' . $crlf . ']+' . $crlf . ')*' .
// Headers are terminated by another CRLF (blank line).
$crlf .
// Second HTTP status code, this time must be 200.
'(HTTP/1.[01] 200 )~', '$1', $input);
'(HTTP/[1-9](\.[0-9])? 200)~', '$2', $input);
}
}