mirror of
https://github.com/vrana/adminer.git
synced 2026-01-10 09:33:06 +01:00
PostgreSQL: Don't treat user types containing 'file' as blobs (fix #1118)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
- PostgreSQL: Quote edit value with interval operator
|
||||
- PostgreSQL: Fix calling functions with name-less parameters
|
||||
- PostgreSQL: Fix calling functions returing table
|
||||
- PostgreSQL: Don't treat user types containing 'file' as blobs (bug #1118)
|
||||
- PostgreSQL 11-: Avoid duplicate oid in table status (bug #1089)
|
||||
- Elasticsearch: Support dropping aliases
|
||||
- Plugins: Methods afterConnect(), processList() and killProcess()
|
||||
|
||||
@@ -304,7 +304,7 @@ class Adminer {
|
||||
: (preg_match('~json~', $field["type"]) ? "<code class='jush-js'>$val</code>"
|
||||
: $val)
|
||||
));
|
||||
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && !is_utf8($val)) {
|
||||
if (is_blob($field) && !is_utf8($val)) {
|
||||
$return = "<i>" . lang('%d byte(s)', strlen($original)) . "</i>";
|
||||
}
|
||||
return ($link ? "<a href='" . h($link) . "'" . (is_url($link) ? target_blank() : "") . ">$return</a>" : $return);
|
||||
@@ -703,7 +703,7 @@ class Adminer {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($key && $functions && !preg_match('~set|blob|bytea|raw|file|bool~', $field["type"])) {
|
||||
if ($key && $functions && !preg_match('~set|bool~', $field["type"]) && !is_blob($field)) {
|
||||
$return .= "/SQL";
|
||||
}
|
||||
}
|
||||
@@ -843,7 +843,7 @@ class Adminer {
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = connection()->query($query, 1); // 1 - MYSQLI_USE_RESULT //! enum and set as numbers
|
||||
$result = connection()->query($query, 1); // 1 - MYSQLI_USE_RESULT
|
||||
if ($result) {
|
||||
$insert = "";
|
||||
$buffer = "";
|
||||
|
||||
@@ -791,6 +791,13 @@ function select_value($val, string $link, array $field, ?string $text_length): s
|
||||
return adminer()->selectVal($return, $link, $field, $val);
|
||||
}
|
||||
|
||||
/** Check whether the field type is blob or equivalent
|
||||
* @param Field $field
|
||||
*/
|
||||
function is_blob(array $field): bool {
|
||||
return preg_match('~blob|bytea|raw|file~', $field["type"]) && !in_array($field["type"], idx(driver()->structuredTypes(), lang('User types'), array()));
|
||||
}
|
||||
|
||||
/** Check whether the string is e-mail address */
|
||||
function is_mail(?string $email): bool {
|
||||
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // characters of local-name
|
||||
|
||||
@@ -240,7 +240,7 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
$checked = in_array($val, explode(",", $value), true);
|
||||
echo " <label><input type='checkbox' name='fields[$name][$i]' value='" . h($val) . "'" . ($checked ? ' checked' : '') . ">" . h(adminer()->editVal($val, $field)) . '</label>';
|
||||
}
|
||||
} elseif (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) {
|
||||
} elseif (is_blob($field) && ini_bool("file_uploads")) {
|
||||
echo "<input type='file' name='fields-$name'>";
|
||||
} elseif ($function == "json" || preg_match('~^jsonb?$~', $field["type"])) {
|
||||
echo "<textarea$attrs cols='50' rows='12' class='jush-js'>" . h($value) . '</textarea>';
|
||||
@@ -324,7 +324,7 @@ function process_input(array $field) {
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) {
|
||||
if (is_blob($field) && ini_bool("file_uploads")) {
|
||||
$file = get_file("fields-$idf");
|
||||
if (!is_string($file)) {
|
||||
return false; //! report errors
|
||||
|
||||
@@ -423,7 +423,7 @@ if (!$columns && support("table")) {
|
||||
}
|
||||
|
||||
$link = "";
|
||||
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && $val != "") {
|
||||
if (is_blob($field) && $val != "") {
|
||||
$link = ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf;
|
||||
}
|
||||
if (!$link && $val !== null) { // link related items
|
||||
|
||||
@@ -219,7 +219,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
|
||||
function selectVal($val, $link, $field, $original) {
|
||||
$return = $val;
|
||||
$link = h($link);
|
||||
if (preg_match('~blob|bytea~', $field["type"]) && !is_utf8($val)) {
|
||||
if (is_blob($field) && !is_utf8($val)) {
|
||||
$return = lang('%d byte(s)', strlen($original));
|
||||
if (preg_match("~^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)~", $original)) { // GIF|JPG|PNG, getimagetype() works with filename
|
||||
$return = "<img src='$link' alt='$return'>";
|
||||
|
||||
Reference in New Issue
Block a user