Ramble On

Rambles of a University Systems Manager

Archive for March 21st, 2007

No quarters, no nikes, none of the time

without comments

Written by jayoung

March 21st, 2007 at 9:32 pm

Posted in Uncategorized

Tagged with , ,

Uploading KML files to MediaWiki

without comments

So you want to upload KML files to your MediaWiki install? Simple as putting ‘kml’ in your allowed file extensions right?

Wrong.

Through the almighty power of a string match that’s not actually a regular expression, but instead a strpos match in the SpecialUpload:detectScript function (yes, that’s right, a strpos match, not a stripos match - but a strtolower takes care of that a few lines before - that’s probably faster anyway).

The strpos looks for <head in the chunk o’ text that’s in the uploaded file - which of course matches the KML heading tag - producing a detectScript match

Yes, one could modify the function in MediaWiki to handle KML file uploads - pulling <head out of the following code block:

		$tags = array(
			'<body',
			'<head',
			'<html',   #also in safari
			'<img',
			'<pre',
			'<script', #also in safari
			'<table'
			);
		if( ! $wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) {
			$tags[] = '<title';
		}

		foreach( $tags as $tag ) {
			if( false !== strpos( $chunk, $tag ) ) {
				return true;
			}
		}

And then writing a regex to match <head and not <heading

Which is certainly do-able due to the beauty of open-source software(*) But thankfully (very thankfully) there’s a KMZ (scroll down) format. Which should upload just fine with just a file extension addition. (And the bonus is that it’s far more feature-rich to use.)

(* which, of course, making custom local modifications to your open-source software packages that don’t merit patch submissions back to the package authors is a whole other discussion topic, look for the future post and/or Conversations with Plastic Dinosaurs about being on the hook to maintain custom changes change for any and all future updates to the open-source software packages you use, which inevitably, you’ll forget you made, and then you’ll upgrade, and you’ll break expected functionality, which won’t be noticed for months after you’ve forgotten you ever even upgraded, at which point someone will complain, memos will be written, you’ll get blamed, you’ll bitch about getting blamed, everyone but you, given that you actually do the work, will promise not to forget about it again, which you’ll promptly do six months and thousands of tasks later on the next upgrade. Lather, Rinse, Repeat. )

Written by jayoung

March 21st, 2007 at 11:55 am

Posted in Uncategorized

Tagged with

It ain’t magic

without comments

Dealing with magic, magic.mime, and mime.types on Red Hat Enterprise Linux and with PHP, FileInfo, and MediaWiki is a serious pain in the ass.

Who in hell came up with this mess? Apache has a magic file, the os has a magic file, FileInfo complains that it can’t find /usr/share/misc/magic - when it’s really looking for /usr/share/misc/magic.mime. There’s about twenty billion mime.types files - including the one that MediaWiki has itself. And there’s that many symlinks from hell trying to link some of these together.

What a freakin’ cluster-you-know-what.

Written by jayoung

March 21st, 2007 at 10:48 am

Posted in Uncategorized

Tagged with ,