Code Duplication    Length = 7-7 lines in 2 locations

includes/upload/UploadBase.php 2 locations

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