Code Duplication    Length = 7-7 lines in 2 locations

includes/upload/UploadBase.php 2 locations

@@ 1220-1226 (lines=7) @@
1217
		$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
1218
1219
		if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
1220
			if ( preg_match( $encodingRegex, $matches[1], $encMatch )
1221
				&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
1222
			) {
1223
				wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" );
1224
1225
				return true;
1226
			}
1227
		} elseif ( preg_match( "!<\?xml\b!si", $contents ) ) {
1228
			// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
1229
			// bytes. There shouldn't be a legitimate reason for this to happen.
@@ 1248-1254 (lines=7) @@
1245
			$str = iconv( $encoding, 'UTF-8', $contents );
1246
			MediaWiki\restoreWarnings();
1247
			if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) {
1248
				if ( preg_match( $encodingRegex, $matches[1], $encMatch )
1249
					&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
1250
				) {
1251
					wfDebug( __METHOD__ . ": Found unsafe XML encoding '{$encMatch[1]}'\n" );
1252
1253
					return true;
1254
				}
1255
			} elseif ( $str != '' && preg_match( "!<\?xml\b!si", $str ) ) {
1256
				// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
1257
				// bytes. There shouldn't be a legitimate reason for this to happen.