X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FOutputHandler.php;h=3860b8e2b384a69ab1526de947575f44baa2629c;hb=aea3a5dce215b9f3929d65365fe9bd101ecdf07d;hp=e7928cc0e48b3c20c4f46509b37715913bd70e42;hpb=117424d9e57256ffb1c27f17ba6eb004d3944ce1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputHandler.php b/includes/OutputHandler.php index e7928cc0e4..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; } } @@ -177,20 +185,8 @@ function wfHtmlValidationHandler( $s ) { header( 'Cache-Control: no-cache' ); - $out = << - - -HTML validation error - - - -

HTML validation error

-'; - $out .= '
' . htmlspecialchars( $errors ) . '
'; - $out .= "
    \n"; + $out .= Html::closeElement( 'ul' ); + $out .= Html::element( 'pre', null, $errors ); + $out .= Html::openElement( 'ol' ) . "\n"; $line = strtok( $s, "\n" ); $i = 1; while ( $line !== false ) { + $attrs = array(); if ( isset( $badLines[$i] ) ) { - $out .= "
  1. "; - } else { - $out .= '
  2. '; + $attrs['class'] = 'highlight'; + $attrs['id'] = "line-$i"; } - $out .= htmlspecialchars( $line ) . "
  3. \n"; + $out .= Html::element( 'li', $attrs, $line ) . "\n"; $line = strtok( "\n" ); $i++; } - $out .= '
'; + $out .= Html::closeElement( 'ol' ); + + $style = << 'en', 'dir' => 'ltr' ) ) . + Html::rawElement( 'head', null, + Html::element( 'title', null, 'HTML validation error' ) . + Html::inlineStyle( $style ) ) . + Html::rawElement( 'body', null, $out ) . + Html::closeElement( 'html' ); + return $out; }