From ec4dbd13cdd39d1b2b3e9a596f8609eadd7219b5 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Sat, 19 Feb 2011 03:22:03 +0000 Subject: [PATCH] =?utf8?q?Bug=20#26059=20=E2=80=94=20Add=20support=20for?= =?utf8?q?=20KML/KMZ=20filetype?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 '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', ); /** diff --git a/includes/Defines.php b/includes/Defines.php index 64197d9c48..de32a6be4b 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -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) /**@}*/ /**@{ diff --git a/includes/mime.info b/includes/mime.info index 9b5427150a..b8027684c7 100644 --- a/includes/mime.info +++ b/includes/mime.info @@ -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] diff --git a/includes/mime.types b/includes/mime.types index 3cb5e5e73d..ad4489f69a 100644 --- a/includes/mime.types +++ b/includes/mime.types @@ -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 diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 9549504db8..5f5dcfabd0 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -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; } -- 2.20.1