Page MenuHomePhabricator

Error uploading file where it has backslahes in file metadata using PostgreSQL 9.1.9
Closed, ResolvedPublic

Description

Author: erich.lerch

Description:
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


Version: 1.20.x
Severity: normal
OS: Linux

Attached:

Details

Reference
bz52017

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 1:45 AM
bzimport set Reference to bz52017.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Jul 25 2013, 9:31 AM

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!

Gilles raised the priority of this task from Normal to Unbreak Now!.Dec 4 2014, 10:24 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Normal.Dec 4 2014, 11:22 AM
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.

Restricted Application added a project: Commons. · View Herald TranscriptNov 2 2016, 8:16 PM
Restricted Application added a subscriber: Matanya. · View Herald Transcript