Code Duplication    Length = 7-7 lines in 2 locations

includes/upload/UploadBase.php 2 locations

@@ 1301-1307 (lines=7) @@
1298
		$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
1299
1300
		if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
1301
			if ( preg_match( $encodingRegex, $matches[1], $encMatch )
1302
				&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
1303
			) {
1304
				wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" );
1305
1306
				return true;
1307
			}
1308
		} elseif ( preg_match( "!<\?xml\b!si", $contents ) ) {
1309
			// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
1310
			// bytes. There shouldn't be a legitimate reason for this to happen.
@@ 1329-1335 (lines=7) @@
1326
			$str = iconv( $encoding, 'UTF-8', $contents );
1327
			MediaWiki\restoreWarnings();
1328
			if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) {
1329
				if ( preg_match( $encodingRegex, $matches[1], $encMatch )
1330
					&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
1331
				) {
1332
					wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" );
1333
1334
					return true;
1335
				}
1336
			} elseif ( $str != '' && preg_match( "!<\?xml\b!si", $str ) ) {
1337
				// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
1338
				// bytes. There shouldn't be a legitimate reason for this to happen.