* @return string
*/
function wfOutputHandler( $s ) {
- global $wgDisableOutputCompression, $wgValidateAllHtml;
- $s = wfMangleFlashPolicy( $s );
+ global $wgDisableOutputCompression, $wgValidateAllHtml, $wgMangleFlashPolicy;
+ if ( $wgMangleFlashPolicy ) {
+ $s = wfMangleFlashPolicy( $s );
+ }
if ( $wgValidateAllHtml ) {
$headers = headers_list();
$isHTML = false;
$headers = headers_list();
$foundVary = false;
foreach ( $headers as $header ) {
- if ( substr( $header, 0, 5 ) == 'Vary:' ) {
+ $headerName = strtolower( substr( $header, 0, 5 ) );
+ if ( $headerName == 'vary:' ) {
$foundVary = true;
break;
}
}
if ( !$foundVary ) {
header( 'Vary: Accept-Encoding' );
- global $wgUseXVO;
- if ( $wgUseXVO ) {
- header( 'X-Vary-Options: Accept-Encoding;list-contains=gzip' );
+ global $wgUseKeyHeader;
+ if ( $wgUseKeyHeader ) {
+ header( 'Key: Accept-Encoding;match=gzip' );
}
}
return $s;
*/
function wfMangleFlashPolicy( $s ) {
# Avoid weird excessive memory usage in PCRE on big articles
- if ( preg_match( '/\<\s*cross-domain-policy\s*\>/i', $s ) ) {
- return preg_replace( '/\<\s*cross-domain-policy\s*\>/i', '<NOT-cross-domain-policy>', $s );
+ if ( preg_match( '/\<\s*cross-domain-policy(?=\s|\>)/i', $s ) ) {
+ return preg_replace( '/\<(\s*)(cross-domain-policy(?=\s|\>))/i', '<$1NOT-$2', $s );
} else {
return $s;
}
}
/**
- * Add a Content-Length header if possible. This makes it cooperate with squid better.
+ * Add a Content-Length header if possible. This makes it cooperate with CDN better.
*
* @param int $length
*/
$out .= Html::openElement( 'ul' );
$error = strtok( $errors, "\n" );
- $badLines = array();
+ $badLines = [];
while ( $error !== false ) {
if ( preg_match( '/^line (\d+)/', $error, $m ) ) {
$lineNum = intval( $m[1] );
$badLines[$lineNum] = true;
$out .= Html::rawElement( 'li', null,
- Html::element( 'a', array( 'href' => "#line-{$lineNum}" ), $error ) ) . "\n";
+ Html::element( 'a', [ 'href' => "#line-{$lineNum}" ], $error ) ) . "\n";
}
$error = strtok( "\n" );
}
$line = strtok( $s, "\n" );
$i = 1;
while ( $line !== false ) {
- $attrs = array();
+ $attrs = [];
if ( isset( $badLines[$i] ) ) {
$attrs['class'] = 'highlight';
$attrs['id'] = "line-$i";
li { white-space: pre }
CSS;
- $out = Html::htmlHeader( array( 'lang' => 'en', 'dir' => 'ltr' ) ) .
+ $out = Html::htmlHeader( [ 'lang' => 'en', 'dir' => 'ltr' ] ) .
Html::rawElement( 'head', null,
Html::element( 'title', null, 'HTML validation error' ) .
Html::inlineStyle( $style ) ) .