https://bugzilla.wikimedia.org/show_bug.cgi?id=4421
Rob Lanphier (RobLa) <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #27 from Rob Lanphier (RobLa) <[email protected]> 2009-10-18 05:47:20 UTC --- I started looking at this problem to see if I could work up the first baby step patch toward allowing arbitrary file names, which is to allow moving an image to an arbitrary location. I first just tried removing checkExtensionCompatibility from Title::isValidMoveOperation(). That mostly seems to work, but the hitch comes when you try to reference the bare image URL, because that's served directly from the webserver, which typically relies on the file extension to get the media type. So, regardless of how MediaWiki refers to the file, it still needs to be stuffed onto disk with a valid extension intact unless you're hosting on some ninja psychic webserver that just knows what the media type of the file is (or perhaps one that's cracking open files to see what's in them). The strategy I cooked up next was to modify FileRepo::getNameFromTitle(). Here was the plan: * Check if the media type from the database matches up with the media type derived from the file name from the title * If they match, do nothing different * If they don't match, tack on the extension to the filename based on the media type I'm not even remotely sure if getNameFromTitle is the right place to insert this sort of thing (I suspect it isn't, actually). I was looking for a place where I could muck with the file name without also mucking with other uses of the name. It seems safer to go elsewhere, like File::getRel and File::getUrlRel. I may play around more with this once I get unstuck. The wall I hit was figuring out the right way to pull the MIME type out of the database, because I think I accidently engaged in a mutually recursive death spiral calling LocalFile::GetMimeType() from there. If anyone has any tips on the right way to pull the mime type for a given Title out, that'd be most helpful. I may putter around with this a bit more this weekend. This isn't a problem I'm planning to bulldog until it's fixed, but it's something I'll post a patch to if I manage to muddle my way into something that seems to work. One hacky workaround that could work ok is to allow arbitrary file names in the upload screen, but instead of rejecting the upload if the name doesn't match a valid MIME type, simply tack the extension onto the end, then put a redirect from the given name to the extended name. That's probably a little too hacky to have the fully desired effect, but it does at least make it a little easier to refer to the file in an extension-agnostic manner. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
