]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Unescape bytea fields
authorJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 15:05:39 +0000 (16:05 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 15:05:50 +0000 (16:05 +0100)
adminer/download.inc.php
adminer/drivers/pgsql.inc.php
adminer/include/driver.inc.php
adminer/select.inc.php
changes.txt

index b1aea655a193724b138978eb409faea37e399830..9afe554c96b3d3ebc3baaf399ac0c21d5031e0c3 100644 (file)
@@ -6,5 +6,5 @@ header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . i
 $select = array(idf_escape($_GET["field"]));
 $result = $driver->select($TABLE, $select, array(where($_GET, $fields)), $select);
 $row = ($result ? $result->fetch_row() : array());
-echo $row[0];
+echo $driver->value($row[0], $fields[$_GET["field"]]);
 exit; // don't output footer
index 02baec0d2a5e47522b361e753b552c800abc571a..b8f40bc44321403820a196b3f23f7d2923e52dd5 100644 (file)
@@ -40,6 +40,10 @@ if (isset($_GET["pgsql"])) {
                                return "'" . pg_escape_string($this->_link, $string) . "'";
                        }
 
+                       function value($val, $field) {
+                               return ($field["type"] == "bytea" ? pg_unescape_bytea($val) : $val);
+                       }
+
                        function quoteBinary($string) {
                                return "'" . pg_escape_bytea($this->_link, $string) . "'";
                        }
@@ -151,6 +155,10 @@ if (isset($_GET["pgsql"])) {
                                return ($adminer->database() == $database);
                        }
 
+                       function value($val, $field) {
+                               return $val;
+                       }
+
                        function quoteBinary($s) {
                                return q($s);
                        }
@@ -196,6 +204,10 @@ if (isset($_GET["pgsql"])) {
                        );
                }
 
+               function value($val, $field) {
+                       return $this->_conn->value($val, $field);
+               }
+
                function quoteBinary($s) {
                        return $this->_conn->quoteBinary($s);
                }
index 6e35b4fab4116bd1bfee2b40b37c9dd65bd211ea..1a4e86ea8caef37eb7999443bc0778e19a3afb5a 100644 (file)
        function convertSearch($idf, $val, $field) {
                return $idf;
        }
-       
+
+       /** Convert value returned by database to actual value
+       * @param string
+       * @param array
+       * @return string
+       */
+       function value($val, $field) {
+               return $val;
+       }
+
        /** Quote binary string
        * @param string
        * @return string
index 328602d3c77621a57f6b81775910eb58dc6053c8..f165d1a24e3cdf922edfef629373342e8f8a63bc 100644 (file)
@@ -391,6 +391,7 @@ if (!$columns && support("table")) {
                                foreach ($row as $key => $val) {
                                        if (isset($names[$key])) {
                                                $field = $fields[$key];
+                                               $val = $driver->value($val, $field);
                                                if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
                                                        $email_fields[$key] = (is_mail($val) ? $names[$key] : ""); //! filled e-mails can be contained on other pages
                                                }
index 47e4c91cc725cb62dd8aa8f56f262d17eb337ff4..87cfb4853b78271f817d90bddaa1adf458151d80 100644 (file)
@@ -1,7 +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: Support binary files in 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