Last modified: 2010-01-22 00:56:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T22751, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 20751 - ForeignApiRepo does not urldecode filenames
ForeignApiRepo does not urldecode filenames
Status: CLOSED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
1.16.x
PC Linux
: Normal major (vote)
: ---
Assigned To: Chad H.
http://www.wikimania2010.pl/wiki/U%C5...
: i18n, patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-21 01:10 UTC by Marcin Cieślak
Modified: 2010-01-22 00:56 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch to ForeignAPIRepo.php rev 56620 that seems to fix the issue (669 bytes, patch)
2009-09-21 01:10 UTC, Marcin Cieślak
Details

Description Marcin Cieślak 2009-09-21 01:10:31 UTC
Created attachment 6566 [details]
patch to ForeignAPIRepo.php rev 56620 that seems to fix the issue

I run an non-Wikimedia MediaWiki on www.wikimania2010.pl. This MediaWiki installation uses commons as its image backend,
this was working properly since we setup the site.

The site was running rev502xx-something but the users complained that some images from Commons do not get displayed on the site. I have upgraded the site to 1.16alpha (r56620) but the problem remained. In the debug log one can see:

Saved preprocessor XML to memcached (key wikimania2010db:preprocess-xml:fba7984c25b803a608bd8d256bb00be0:0)
File::transform: Doing stat for /home/upload/www.wikimania2010.pl/thumb/5/52/WikimaniaGdańsk2010.svg/600px-WikimaniaGdańsk2010.svg.png
ForeignAPIRepo::getThumbUrl got remote thumb http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/POL_Gda%C5%84sk_COA.svg/400px-POL_Gda%C5%84sk_COA.svg.p
ng
ForeignAPIRepo::getThumbUrlFromCache got local thumb http://www.wikimania2010.pl/upload/www.wikimania2010.pl/thumb/POL_Gdańsk_COA.svg/400px-POL_Gda%C5%84sk_C
OA.svg.png, saving to cache 

Please note that URL is full URL-encoded. But the "local thumb" URL is partially encoded: the directory path is in plain UTF-8, the file name is URL-encoded. Actually the Apache webserver requires that names will be stored in UTF-8, otherwise a 404 will be returned (if 400px-POL_Gda%C5%84sk_COA.svg.png is requested and 400px-POL_Gda%C5%84sk_COA.svg.png exists). 

As of 1.16alpha-wmf (r56620), Commons returns URL-encoded thumbnail URL as a reponse to the query (examples from a different image):

Query:
http://commons.wikimedia.org/w/api.php?titles=Image%3AO%C5%82owianka_Island_04.jpeg&iiprop=url&iiurlwidth=810&iiurlheight=-1&prop=imageinfo&format=json&actio
n=query

Response:
{"query":{"normalized":[{"from":"Image:O\u0142owianka_Island_04.jpeg","to":"File:O\u0142owianka Island 04.jpeg"}],"pages":{"6530939":{"pageid":6530939,"ns":6
,"title":"File:O\u0142owianka Island 04.jpeg","imagerepository":"local","imageinfo":[{"thumburl":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/e
\/e2\/O%C5%82owianka_Island_04.jpeg\/810px-O%C5%82owianka_Island_04.jpeg","thumbwidth":810,"thumbheight":184,"url":"http:\/\/upload.wikimedia.org\/wikipedia\
/commons\/e\/e2\/O%C5%82owianka_Island_04.jpeg","descriptionurl":"http:\/\/commons.wikimedia.org\/wiki\/File:O%C5%82owianka_Island_04.jpeg"}]}}}}

However, ForeignAPIRepo->getThumbUrlFromCache just takes the last element of the filename and passes it as-is over to the filesystem. Unfortunately, any URL-encoded characters in the thumbnail URL will be used as they are in the filename.

Unfortunately I couldn't replicate this problem on Wikimedia wikis.

I don't know if the API output has changed or is this some older problem - the patch attached seems to fix the issue for me.
Comment 1 Chad H. 2009-09-21 01:33:24 UTC
Fixed in r56694.
Comment 2 Marcin Cieślak 2010-01-22 00:56:55 UTC
Works fine (tested last time in r61343)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links