From 559afbf6d3a92123f0805ab89a932488b6c8506b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 14 May 2013 07:57:34 +0200 Subject: [PATCH] Fix fatal error when $wgValidateAllHtml is enabled and apache_request_headers() does not exists Changed apache_request_headers() to headers_list() since the latter is always available Change-Id: Ia52f5a0d12db0680aa03b57dd45c974291e88af9 --- RELEASE-NOTES-1.22 | 2 ++ includes/OutputHandler.php | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index c1f91bc83b..0b1cc17953 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -218,6 +218,8 @@ production. * (bug 50870) mediawiki.notification: Notification area should remain visible when scrolled down. * (bug 13438) Special:MIMESearch no longer an expensive special page. +* (bug 48342) Fixed a fatal error when $wgValidateAllHtml is set to true and + the function apache_request_headers() function is not available. === API changes in 1.22 === * (bug 25553) The JSON output formatter now leaves forward slashes unescaped diff --git a/includes/OutputHandler.php b/includes/OutputHandler.php index 5104a1ab04..3860b8e2b3 100644 --- a/includes/OutputHandler.php +++ b/includes/OutputHandler.php @@ -31,11 +31,19 @@ function wfOutputHandler( $s ) { global $wgDisableOutputCompression, $wgValidateAllHtml; $s = wfMangleFlashPolicy( $s ); if ( $wgValidateAllHtml ) { - $headers = apache_response_headers(); - $isHTML = true; - foreach ( $headers as $name => $value ) { - if ( strtolower( $name ) == 'content-type' && strpos( $value, 'text/html' ) === false && strpos( $value, 'application/xhtml+xml' ) === false ) { - $isHTML = false; + $headers = headers_list(); + $isHTML = false; + foreach ( $headers as $header ) { + $parts = explode( ':', $header, 2 ); + if ( count( $parts ) !== 2 ) { + continue; + } + $name = strtolower( trim( $parts[0] ) ); + $value = trim( $parts[1] ); + if ( $name == 'content-type' && ( strpos( $value, 'text/html' ) === 0 + || strpos( $value, 'application/xhtml+xml' ) === 0 ) + ) { + $isHTML = true; break; } } -- 2.20.1