PostgreSQL: Unescape bytea fields

This commit is contained in:
Jakub Vrana 2018-02-06 16:05:39 +01:00
parent 29c127e94a
commit 19653de764
5 changed files with 25 additions and 3 deletions

View 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

View 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);
}

View file

@ -122,7 +122,16 @@
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

View 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
}

View 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