Escape backslashes in image metadata
authorErich Lerch <erich.lerch@wien.gv.at>
Tue, 15 Oct 2013 23:09:27 +0000 (01:09 +0200)
committersaper <saper@saper.info>
Tue, 15 Oct 2013 23:09:27 +0000 (01:09 +0200)
Uploading a file with backslashes in the metadata
causes database exception on PostgreSQL, because
backslashes are sent to the 'bytea' datatype unencoded.

Bug: 52017
Change-Id: Ife56cffe3df83ec1a7bd39cdc4a0489f23354494

includes/filerepo/file/LocalFile.php

index 627defd..0c34f3e 100644 (file)
@@ -539,7 +539,7 @@ class LocalFile extends File {
                                'img_media_type' => $this->media_type,
                                'img_major_mime' => $major,
                                'img_minor_mime' => $minor,
-                               'img_metadata' => $this->metadata,
+                               'img_metadata' => $dbw->encodeBlob($this->metadata),
                                'img_sha1' => $this->sha1,
                        ),
                        array( 'img_name' => $this->getName() ),
@@ -1225,7 +1225,7 @@ class LocalFile extends File {
                                'img_description' => $comment,
                                'img_user' => $user->getId(),
                                'img_user_text' => $user->getName(),
-                               'img_metadata' => $this->metadata,
+                               'img_metadata' => $dbw->encodeBlob($this->metadata),
                                'img_sha1' => $this->sha1
                        ),
                        __METHOD__,
@@ -1276,7 +1276,7 @@ class LocalFile extends File {
                                        'img_description' => $comment,
                                        'img_user'        => $user->getId(),
                                        'img_user_text'   => $user->getName(),
-                                       'img_metadata'    => $this->metadata,
+                                       'img_metadata'    => $dbw->encodeBlob($this->metadata),
                                        'img_sha1'        => $this->sha1
                                ),
                                array( 'img_name' => $this->getName() ),