]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Upload binary files to bytea fields
authorJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 14:42:14 +0000 (15:42 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 14:42:14 +0000 (15:42 +0100)
adminer/drivers/pgsql.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
changes.txt

index 440bc1a86bfe6992a820db6b2365b2d34615772f..02baec0d2a5e47522b361e753b552c800abc571a 100644 (file)
@@ -37,7 +37,11 @@ if (isset($_GET["pgsql"])) {
                        }
 
                        function quote($string) {
-                               return "'" . pg_escape_string($this->_link, $string) . "'"; //! bytea
+                               return "'" . pg_escape_string($this->_link, $string) . "'";
+                       }
+
+                       function quoteBinary($string) {
+                               return "'" . pg_escape_bytea($this->_link, $string) . "'";
                        }
 
                        function select_db($database) {
@@ -147,6 +151,10 @@ if (isset($_GET["pgsql"])) {
                                return ($adminer->database() == $database);
                        }
 
+                       function quoteBinary($s) {
+                               return q($s);
+                       }
+
                        function warnings() {
                                return ''; // not implemented in PDO_PgSQL as of PHP 7.2.1
                        }
@@ -188,6 +196,10 @@ if (isset($_GET["pgsql"])) {
                        );
                }
 
+               function quoteBinary($s) {
+                       return $this->_conn->quoteBinary($s);
+               }
+
                function warnings() {
                        return $this->_conn->warnings();
                }
index 4a2ae22242a616f5d7261f2bfe298c266ab5df51..6e35b4fab4116bd1bfee2b40b37c9dd65bd211ea 100644 (file)
                return $idf;
        }
        
+       /** Quote binary string
+       * @param string
+       * @return string
+       */
+       function quoteBinary($s) {
+               return q($s);
+       }
+       
        /** Get warnings about the last command
        * @return string HTML
        */
index 1576a21b9ae4ce8e23def5785c22b12e08574a34..be2e92e10640a874216a27ce019c4cbfabdab2e1 100644 (file)
@@ -1003,7 +1003,7 @@ function input($field, $value, $function) {
 * @return string or false to leave the original value
 */
 function process_input($field) {
-       global $adminer;
+       global $adminer, $driver;
        $idf = bracket_escape($field["field"]);
        $function = $_POST["function"][$idf];
        $value = $_POST["fields"][$idf];
@@ -1041,7 +1041,7 @@ function process_input($field) {
                if (!is_string($file)) {
                        return false; //! report errors
                }
-               return q($file);
+               return $driver->quoteBinary($file);
        }
        return $adminer->processInput($field, $value, $function);
 }
index 7cbe57c09db1f95d9157e5fca239b667363ea32c..47e4c91cc725cb62dd8aa8f56f262d17eb337ff4 100644 (file)
@@ -1,6 +1,7 @@
 Adminer 4.6.1-dev:
 MySQL: Support non-utf8 charset in search in column
 MySQL: Support geometry in MySQL 8 (bug #574)
+PostgreSQL: Upload binary files to bytea fields
 PostgreSQL: Cast to string when searching using LIKE (bug #325)
 PostgreSQL: Don't treat interval type as number (bug #474)
 PostgreSQL: Fix condition for selecting no rows