Last modified: 2011-09-07 14:45:27 UTC
See https://secure.wikimedia.org/wikipedia/en/wiki/File:Ex_1%25_ample.jpg. Both of the thumbnails in the file history section do not show up. When I go to the URL of the first thumbnail (http://upload.wikimedia.org/wikipedia/en/thumb/d/db/Ex_1%25_ample.jpg/111px-Ex_1%25_ample.jpg) in my browser, I get the following error: <blockquote> Error generating thumbnail Error creating thumbnail: convert: unable to open image `/mnt/thumbs/wikipedia/en/thumb/d/db/Ex_1%%_ample.jpg/111px-Ex_1%%_ample.jpg': @ error/blob.c/OpenBlob/2498. </blockquote> Something is wrong with URL decoding, causing the %25 in the URL to get converted to %% instead of %. (This originally got reported on [[w:WP:VPT]] (https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Wikipedia:Village_pump_%28technical%29&oldid=448818820#Broken_thumbnail); the problematic file was fixed by renaming it to a title that didn't contain the percent sign.)
Ok, so the good news is the bug isn't in thumb-handler.php etc. :) Seems odd... With this original URL: http://upload.wikimedia.org/wikipedia/en/thumb/archive/d/db/20110906223017!Ex_1%25_ample.jpg/111px-Ex_1%25_ample.jpg it should be getting run via the thumb-handler.php on the upload server's 404 handler: http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/upload-scripts/thumb-handler.php?view=markup which should end up fetching something like: http://en.wikipedia.org/w/thumb.php?f=20110906223017!Ex_1%25_ample.jpg&width=111&archived=1 This gives the same error when we fetch it directly: Error generating thumbnail Error creating thumbnail: convert: unable to open image `/mnt/thumbs/wikipedia/en/thumb/archive/d/db/20110906223017!Ex_1%%_ample.jpg/111px-Ex_1%%_ample.jpg': @ error/blob.c/OpenBlob/2498. Now, the '1%%' looks wrong -- it should be '1%' here. So, the good news is: * it's not in thumb-handler.php (whew!) since it happens to direct thumb.php calls * it does the same for archived and current version files And in fact I can reproduce it locally simply by uploading a local copy of 'Ex 1% ample.jpg' and trying to see the current-version page. This shows an error right there on the page.
r65467: /** * Escape a string for ImageMagick's output filename. See * InterpretImageFilename() in magick/image.c. */ function escapeMagickOutput( $path, $scene = false ) { $path = str_replace( '%', '%%', $path ); return $this->escapeMagickPath( $path, $scene ); } So... it seems to be doing this on purpose... perhaps that purpose has gone obsolete or something else is funky.
That was added in as a fix for bug 23148 -- originally more simply and only on the comment field. r65467 later applied the same replacement to other fields including the destination filename, and another special replacement for the input filename. Possibly this is wrong for the output filename?
Behavior seems to have changed -- if I compile ImageMagick 6.6.9 locally it goes ahead and processes the file, whereas the 6.6.2 that shipped with Ubuntu 11.04 complains about the %% form... 2011-01-10 6.6.7-1 Cristy <quetzlzacatenango@image...> * Accept escaped % in output filename (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=17810). Bingo!
I've filed an RT ticket internally to request that our deployed ImageMagick get updated: http://rt.wikimedia.org/Ticket/Display.html?id=1444
Thanks for the investigation and for finding the solution. *** This bug has been marked as a duplicate of bug 26233 ***
Percents in file names are perhaps too funky too allow. There are so many things that can break with it; perhaps it is better to just disallow it totally.
That makes sense to me, but it would be problematic because there are actually quite a few files with percent signs in their filenames (e.g., http://commons.wikimedia.org/wiki/File:25%25.svg, http://commons.wikimedia.org/wiki/File:25%25.png). Those are either SVGs, which aren't affected by this bug, or PNGs so small that they don't get thumbnailed. I have no idea how many more there may be, since I can't find a way to search for them on-wiki (intitle:% doesn't work, and Googling inurl:%25 doesn't work either).