|
@@ 1285-1291 (lines=7) @@
|
| 1282 |
|
$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si'; |
| 1283 |
|
|
| 1284 |
|
if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) { |
| 1285 |
|
if ( preg_match( $encodingRegex, $matches[1], $encMatch ) |
| 1286 |
|
&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings ) |
| 1287 |
|
) { |
| 1288 |
|
wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" ); |
| 1289 |
|
|
| 1290 |
|
return true; |
| 1291 |
|
} |
| 1292 |
|
} elseif ( preg_match( "!<\?xml\b!si", $contents ) ) { |
| 1293 |
|
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff |
| 1294 |
|
// bytes. There shouldn't be a legitimate reason for this to happen. |
|
@@ 1313-1319 (lines=7) @@
|
| 1310 |
|
$str = iconv( $encoding, 'UTF-8', $contents ); |
| 1311 |
|
MediaWiki\restoreWarnings(); |
| 1312 |
|
if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) { |
| 1313 |
|
if ( preg_match( $encodingRegex, $matches[1], $encMatch ) |
| 1314 |
|
&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings ) |
| 1315 |
|
) { |
| 1316 |
|
wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" ); |
| 1317 |
|
|
| 1318 |
|
return true; |
| 1319 |
|
} |
| 1320 |
|
} elseif ( $str != '' && preg_match( "!<\?xml\b!si", $str ) ) { |
| 1321 |
|
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff |
| 1322 |
|
// bytes. There shouldn't be a legitimate reason for this to happen. |