Last modified: 2013-10-15 23:29:35 UTC
Created attachment 12955 [details] zip-file which contains the patch-file and image with backslashes in its metadata Hello, I have installed mediawiki 1.20.0 on a RHEL system with a PostgreSQL 9.1.9 database. When i try to upload a file which contains backslashes in its metadata i get the following error: <--- snip ---> A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: INSERT INTO "image" (img_name,img_size,img_width,img_height,img_bits,img_media_type,img_major_mime,img_minor_mime,img_timestamp,img_description,img_user,img_user_text,img_metadata,img_sha1) VALUES ('PO_02.png','21440','825','704','8','BITMAP','image','png','2013-07-25 08:59:43 GMT','','92','<username>','a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:16:"truecolour-alpha";s:8:"metadata";a:5:{s:11:"XResolution";s:8:"3780/100";s:11:"YResolution";s:8:"3780/100";s:14:"ResolutionUnit";i:3;s:16:"ImageDescription";a:2:{s:9:"x-default";s:127:"[SCM]actwin,18,18,19,19;Poedit : C:\Documents and Settings\<username>\Desktop\buddypress-de_DE.po poedit 05.04.2012 , 20:47:26";s:5:"_type";s:4:"lang";}s:15:"_MW_PNG_VERSION";i:1;}}','14iv15dq7i5djf63k6w5fl3hjqzki4v') from within function „LocalFile::recordUpload2“. Database returned error „22P02: ERROR: invalid input syntax for type bytea LINE 1: ...013-07-25 08:59:43 GMT','','92','<username>','a:6:{s:10... ^ “. <--- snap ---> This is caused by PostgreSQL because the field metadata in the table image is of the type "bytea" and the backslashes in the SQL-statement aren't encoded. See a possible solution in the attached patch-file. This patch-file is build for the file includes/filerepo/file/LocalFile.php. For testing I have attached a file which caused the error. Yours faithfully, Erich Lerch
Hi Erich! Thanks for your patch! You are welcome to use Developer access https://www.mediawiki.org/wiki/Developer_access to submit this as a Git branch directly into Gerrit: https://www.mediawiki.org/wiki/Git/Tutorial Putting your branch in Git makes it easier to review it quickly. Thanks again! We appreciate your contribution. Also, I highly recommend upgrading 1.20.0 to the latest 1.20.6.
Or if you prefer, you can also submit pull requests on the GitHub mirror[1], which will be automatically synchronised with gerrit. (Pull request comment will become the commit message.) [1] http://github.com/wikimedia/mediawiki-core
Change 90057 had a related patch set uploaded by saper: Escape backslashes in image metadata https://gerrit.wikimedia.org/r/90057
Change 90057 merged by jenkins-bot: Escape backslashes in image metadata https://gerrit.wikimedia.org/r/90057
Thanks for the patch!