Index: includes/MimeMagic.php =================================================================== --- includes/MimeMagic.php (revision 44559) +++ includes/MimeMagic.php (working copy) @@ -38,7 +38,7 @@ image/gif gif image/jpeg jpeg jpg jpe image/png png -image/svg+xml image/svg svg +image/svg+xml image/svg svg svgz image/tiff tiff tif image/vnd.djvu image/x.djvu image/x-djvu djvu image/x-portable-pixmap ppm @@ -399,7 +399,7 @@ 'djvu', 'ogg', 'ogv', 'mid', 'pdf', 'wmf', 'xcf', // XML formats we sure hope we recognize reliably - 'svg', + 'svg', 'svgz', ); return in_array( strtolower( $extension ), $types ); } Index: includes/mime.types =================================================================== --- includes/mime.types (revision 44559) +++ includes/mime.types (working copy) @@ -78,7 +78,7 @@ image/ief ief image/jpeg jpeg jpg jpe image/png png -image/svg+xml svg +image/svg+xml svg svgz image/tiff tiff tif image/vnd.djvu djvu djv image/vnd.wap.wbmp wbmp Index: includes/XmlTypeCheck.php =================================================================== --- includes/XmlTypeCheck.php (revision 44559) +++ includes/XmlTypeCheck.php (working copy) @@ -48,20 +48,46 @@ xml_set_element_handler( $parser, array( $this, 'rootElementOpen' ), false ); $file = fopen( $fname, "rb" ); - do { - $chunk = fread( $file, 32768 ); - $ret = xml_parse( $parser, $chunk, feof( $file ) ); - if( $ret == 0 ) { - // XML isn't well-formed! - fclose( $file ); - xml_parser_free( $parser ); - return; - } - } while( !feof( $file ) ); + $chunk = fread( $file, 16 ); + fclose( $file ); + //GZip magic signature (for .SVGZ, etc.) Repoen using ZLib. + $use_gzip = ( substr( $chunk, 0, 2 ) == "\x1f\x8b" && function_exists( 'gzopen' ) ); + + if ( $use_gzip ) { + + $file = gzopen( $fname, "rb" ); + do { + $chunk = gzread( $file, 32768 ); + $ret = xml_parse( $parser, $chunk, gzeof( $file ) ); + if( $ret == 0 ) { + // XML isn't well-formed! + gzclose( $file ); + xml_parser_free( $parser ); + return; + } + } while( !gzeof( $file ) ); + gzclose( $file ); + + } else { //Plain Text + + $file = fopen( $fname, "rb" ); + do { + $chunk = fread( $file, 32768 ); + $ret = xml_parse( $parser, $chunk, feof( $file ) ); + if( $ret == 0 ) { + // XML isn't well-formed! + fclose( $file ); + xml_parser_free( $parser ); + return; + } + } while( !feof( $file ) ); + fclose( $file ); + + } + $this->wellFormed = true; - fclose( $file ); xml_parser_free( $parser ); } Index: includes/ImageFunctions.php =================================================================== --- includes/ImageFunctions.php (revision 44559) +++ includes/ImageFunctions.php (working copy) @@ -47,7 +47,6 @@ /** * Compatible with PHP getimagesize() - * @todo support gzipped SVGZ * @todo check XML more carefully * @todo sensible defaults *