From a946cdda2d6edb6a24e31b591341f69c343775ac Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 30 Jun 2008 14:46:19 +0000 Subject: [PATCH] Add $wgAdditionalXMLTypes, an array of XML mimetypes we can check for with MimeMagic. --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 5 +++++ includes/MimeMagic.php | 8 +++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 717e4e4e7f..0b31962a0d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -64,6 +64,8 @@ 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 6aae1d6578..6abdd953cc 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -366,6 +366,11 @@ $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 01d33c7e6a..aa495f6689 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -457,6 +457,7 @@ 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', @@ -464,11 +465,12 @@ 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] ) ) { - $mime = $types[$xml->rootElement]; - return $mime; + return $types[$xml->rootElement]; + } elseif( isset( $wgAdditionalXMLTypes[$xml->rootElement] ) ) { + return $wgAdditionalXMLTypes[$xml->rootElement]; } else { - /// Fixme -- this would be the place to allow additional XML type checks return 'application/xml'; } } -- 2.20.1