-function wfOutputHandler( $s ) {
- global $wgDisableOutputCompression, $wgValidateAllHtml, $wgMangleFlashPolicy;
- if ( $wgMangleFlashPolicy ) {
- $s = wfMangleFlashPolicy( $s );
- }
- if ( $wgValidateAllHtml ) {
- $headers = headers_list();
- $isHTML = false;
- foreach ( $headers as $header ) {
- $parts = explode( ':', $header, 2 );
- if ( count( $parts ) !== 2 ) {
- continue;
+class OutputHandler {
+ /**
+ * Standard output handler for use with ob_start.
+ *
+ * @param string $s Web response output
+ * @return string
+ */
+ public static function handle( $s ) {
+ global $wgDisableOutputCompression, $wgValidateAllHtml, $wgMangleFlashPolicy;
+ if ( $wgMangleFlashPolicy ) {
+ $s = self::mangleFlashPolicy( $s );
+ }
+ if ( $wgValidateAllHtml ) {
+ $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;
+ }