Bug #26059 — Add support for KML/KMZ filetype
authorMark A. Hershberger <mah@users.mediawiki.org>
Sat, 19 Feb 2011 03:22:03 +0000 (03:22 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Sat, 19 Feb 2011 03:22:03 +0000 (03:22 +0000)
Patch from Derk-Jan Hartman of which he writes:

    I figured adding kml support would be a breeze, but I had not
    counted on the brain dead browser that is IE6.

    Unfortunately, kml contains the element <heading, which triggers
    the protection in detectScript() that protects from uploads that
    IE6 might mistake for HTML.  It triggers on "<head" not sure if we
    can work around this, but Tim will know.

includes/DefaultSettings.php
includes/Defines.php
includes/mime.info
includes/mime.types
includes/upload/UploadBase.php

index a05259c..489d01c 100644 (file)
@@ -881,6 +881,9 @@ $wgXMLMimeTypes = array(
                'http://www.lysator.liu.se/~alla/dia/:diagram'  => 'application/x-dia-diagram',
                'http://www.w3.org/1999/xhtml:html'                             => 'text/html', // application/xhtml+xml?
                'html'                                                  => 'text/html', // application/xhtml+xml?
+               'http://www.opengis.net/kml/2.1:kml'                    => 'application/vnd.google-earth.kml+xml',
+               'http://www.opengis.net/kml/2.2:kml'                    => 'application/vnd.google-earth.kml+xml',
+               'kml'                                                                                   => 'application/vnd.google-earth.kml+xml',
 );
 
 /**
index 64197d9..de32a6b 100644 (file)
@@ -126,6 +126,7 @@ define( 'MEDIATYPE_OFFICE',     'OFFICE' );      // Office Documents, Spreadshee
 define( 'MEDIATYPE_TEXT',       'TEXT' );        // Plain text (possibly containing program code or scripts)
 define( 'MEDIATYPE_EXECUTABLE', 'EXECUTABLE' );  // binary executable
 define( 'MEDIATYPE_ARCHIVE',    'ARCHIVE' );     // archive file (zip, tar, etc)
+define( 'MEDIATYPE_DATA',       'DATA' );        // A generic data file (like kml and kmz)
 /**@}*/
 
 /**@{
index 9b54271..b802768 100644 (file)
@@ -102,6 +102,6 @@ application/vnd.ms-excel.sheet.macroEnabled.12                                      [OFFICE]
 application/vnd.ms-excel.template.macroEnabled.12                              [OFFICE]
 application/vnd.ms-excel.addin.macroEnabled.12                                 [OFFICE]
 application/vnd.ms-excel.sheet.binary.macroEnabled.12                          [OFFICE]
-
 application/acad application/x-acad application/autocad_dwg image/x-dwg application/dwg application/x-dwg application/x-autocad image/vnd.dwg drawing/dwg [DRAWING]
-
+application/vnd.google-earth.kml+xml [DATA]
+application/vnd.google-earth.kmz     [DATA]
index 3cb5e5e..ad4489f 100644 (file)
@@ -161,3 +161,5 @@ application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
 model/vnd.dwfx+xps dwfx
 application/vnd.ms-xpsdocument xps
 application/x-opc+zip docx dotx docm dotm potx ppsx pptx ppam pptm potm ppsm xlsx xltx xlsm xltm xlam xlsb dwfx xps
+application/vnd.google-earth.kml+xml kml
+application/vnd.google-earth.kmz kmz
index 9549504..5f5dcfa 100644 (file)
@@ -857,6 +857,7 @@ abstract class UploadBase {
 
                foreach( $tags as $tag ) {
                        if( false !== strpos( $chunk, $tag ) ) {
+                               wfDebug( __METHOD__ . ": found something that may make it be mistaken for html: $tag\n" );
                                return true;
                        }
                }
@@ -870,16 +871,19 @@ abstract class UploadBase {
 
                # look for script-types
                if( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
+                       wfDebug( __METHOD__ . ": found script types\n" );
                        return true;
                }
 
                # look for html-style script-urls
                if( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
+                       wfDebug( __METHOD__ . ": found html-style script urls\n" );
                        return true;
                }
 
                # look for css-style script-urls
                if( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
+                       wfDebug( __METHOD__ . ": found css-style script urls\n" );
                        return true;
                }