r82436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82435‎ | r82436 | r82437 >
Date:03:22, 19 February 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Bug #26059 — Add support for KML/KMZ filetype

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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Defines.php (modified) (history)
  • /trunk/phase3/includes/mime.info (modified) (history)
  • /trunk/phase3/includes/mime.types (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadBase.php
@@ -857,6 +857,7 @@
858858
859859 foreach( $tags as $tag ) {
860860 if( false !== strpos( $chunk, $tag ) ) {
 861+ wfDebug( __METHOD__ . ": found something that may make it be mistaken for html: $tag\n" );
861862 return true;
862863 }
863864 }
@@ -870,16 +871,19 @@
871872
872873 # look for script-types
873874 if( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
 875+ wfDebug( __METHOD__ . ": found script types\n" );
874876 return true;
875877 }
876878
877879 # look for html-style script-urls
878880 if( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
 881+ wfDebug( __METHOD__ . ": found html-style script urls\n" );
879882 return true;
880883 }
881884
882885 # look for css-style script-urls
883886 if( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
 887+ wfDebug( __METHOD__ . ": found css-style script urls\n" );
884888 return true;
885889 }
886890
Index: trunk/phase3/includes/Defines.php
@@ -126,6 +126,7 @@
127127 define( 'MEDIATYPE_TEXT', 'TEXT' ); // Plain text (possibly containing program code or scripts)
128128 define( 'MEDIATYPE_EXECUTABLE', 'EXECUTABLE' ); // binary executable
129129 define( 'MEDIATYPE_ARCHIVE', 'ARCHIVE' ); // archive file (zip, tar, etc)
 130+define( 'MEDIATYPE_DATA', 'DATA' ); // A generic data file (like kml and kmz)
130131 /**@}*/
131132
132133 /**@{
Index: trunk/phase3/includes/mime.types
@@ -161,3 +161,5 @@
162162 model/vnd.dwfx+xps dwfx
163163 application/vnd.ms-xpsdocument xps
164164 application/x-opc+zip docx dotx docm dotm potx ppsx pptx ppam pptm potm ppsm xlsx xltx xlsm xltm xlam xlsb dwfx xps
 165+application/vnd.google-earth.kml+xml kml
 166+application/vnd.google-earth.kmz kmz
Index: trunk/phase3/includes/DefaultSettings.php
@@ -881,6 +881,9 @@
882882 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram',
883883 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
884884 'html' => 'text/html', // application/xhtml+xml?
 885+ 'http://www.opengis.net/kml/2.1:kml' => 'application/vnd.google-earth.kml+xml',
 886+ 'http://www.opengis.net/kml/2.2:kml' => 'application/vnd.google-earth.kml+xml',
 887+ 'kml' => 'application/vnd.google-earth.kml+xml',
885888 );
886889
887890 /**
Index: trunk/phase3/includes/mime.info
@@ -102,6 +102,6 @@
103103 application/vnd.ms-excel.template.macroEnabled.12 [OFFICE]
104104 application/vnd.ms-excel.addin.macroEnabled.12 [OFFICE]
105105 application/vnd.ms-excel.sheet.binary.macroEnabled.12 [OFFICE]
106 -
107106 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]
108 -
 107+application/vnd.google-earth.kml+xml [DATA]
 108+application/vnd.google-earth.kmz [DATA]

Follow-up revisions

RevisionCommit summaryAuthorDate
r91109Per CR, revert non debugging stuff from r82436. (KML uploads)btongminh20:31, 29 June 2011

Comments

#Comment by Bryan (talk | contribs)   15:26, 7 April 2011

Will break because img_mediatype is an enum, and a new media type is defined without updating the database tables. I'd suggest to just use MEDIATYPE_OFFICE.

#Comment by TheDJ (talk | contribs)   22:04, 23 June 2011

This should probably be reverted. I never finished the patch, it was just some intermediate work that I did and wanted preserved in case we had a way forward for the <head issue and content sniffing.

#Comment by TheDJ (talk | contribs)   21:08, 29 June 2011

Ah you did a partial revert. Indeed a good idea probably to keep that debug in.

Status & tagging log