From f041d796dbf1cb83a8d8422eeff5df5b2904f7ed Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 2 Jul 2008 23:07:39 +0000 Subject: [PATCH] Revert r36816 for the moment (Add $wgAdditionalXMLTypes, an array of XML mimetypes we can check for with MimeMagic.) I very much like the idea of making this extensible, but the current implementation has a couple problems. I'd recommend addresses the following: * The format of the array isn't documented; it has neither examples nor a description of the content format in its comment. If I wanted to add something to it, I wouldn't know what the result should look like without looking up the code. * Rather than "additional" types, it might be best to simply list *all* the types we recognize in the default array -- then it can be modified and extended in local configuration. This would have the following benefits: ** Allows modifying existing types ** Defaults are an example of format, making the structure self-documenting ** Avoids code duplication -- we only have to check one array, not two, and don't have to worry about their formats getting out of sync. --- RELEASE-NOTES | 2 -- includes/DefaultSettings.php | 5 ----- includes/MimeMagic.php | 8 +++----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 735b2b6c3f..a6e1dd87b7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -64,8 +64,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN previously it was choosen based on $wgParserCacheType * $wgExtensionAliasesFiles option to simplify adding aliases to special pages provided by extensions, in a similar way to $wgExtensionMessagesFiles -* Added $wgAdditionalXMLTypes, an array of XML mimetypes we can check for - with MimeMagic. === New features in 1.13 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6abdd953cc..6aae1d6578 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -366,11 +366,6 @@ $wgMimeDetectorCommand= NULL; # use internal mime_content_type function, availab */ $wgTrivialMimeDetection= false; -/** - * Additional XML types we can allow via mime-detection. - */ -$wgAdditionalXMLTypes = array(); - /** * To set 'pretty' URL paths for actions other than * plain page views, add to this array. For instance: diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index aa495f6689..01d33c7e6a 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -457,7 +457,6 @@ class MimeMagic { */ $xml = new XmlTypeCheck( $file ); if( $xml->wellFormed ) { - global $wgAdditionalXMLTypes; $types = array( 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml', 'svg' => 'image/svg+xml', @@ -465,12 +464,11 @@ class MimeMagic { 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml? 'html' => 'text/html', // application/xhtml+xml? ); - if( isset( $types[$xml->rootElement] ) ) { - return $types[$xml->rootElement]; - } elseif( isset( $wgAdditionalXMLTypes[$xml->rootElement] ) ) { - return $wgAdditionalXMLTypes[$xml->rootElement]; + $mime = $types[$xml->rootElement]; + return $mime; } else { + /// Fixme -- this would be the place to allow additional XML type checks return 'application/xml'; } } -- 2.20.1