From aa3fc2541e22f6e22cb3f4bb62598095ad27341b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 5 Feb 2008 22:50:21 +0000 Subject: [PATCH] More SVG detection fixes based on tests on files downloaded from commons... * Make the autodetection work for UTF-16LE and UTF-16BE XML, which never worked before due to using the wrong string compare length * Allow doctype strings to break over newlines * Detect XML if there's a doctype even if there's no XML header (the xml header isn't required for UTF-8 files) --- includes/MimeMagic.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 90009f5fea..8ba992560e 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -460,25 +460,41 @@ class MimeMagic { $xml_type = "ASCII"; } elseif ( substr( $head, 0, 8 ) == "\xef\xbb\xbf 126 ) { + printf( "\\x%02x", $c ); + } else { + print $head{$i}; + } + } + echo "\n"; + */ } if ( $xml_type ) { if ( $xml_type !== "UTF-8" && $xml_type !== "ASCII" ) { $head = iconv( $xml_type, "ASCII//IGNORE", $head ); } + } - $match = array(); - $doctype = ""; - $tag = ""; + $match = array(); + $doctype = ""; + $tag = ""; - if ( preg_match( '%%sim', - $head, $match ) ) { - $doctype = $match[1]; - } + if ( preg_match( '%%siD', + $head, $match ) ) { + $doctype = $match[1]; + } + + if( $xml_type || $doctype ) { if ( preg_match( '%<(\w+)\b%si', $head, $match ) ) { $tag = $match[1]; } -- 2.20.1