diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 8a0f8e1e..a91850f7 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -114,6 +114,9 @@ function adminer_row_descriptions($rows, $foreign_keys) {
*/
function adminer_select_val($val, $link, $field) {
$return = ($field["type"] == "char" ? "$val
" : $val);
+ if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
+ $return = lang('%d byte(s)', strlen($val));
+ }
return call_adminer('select_val', ($link ? "$return" : $return), $val, $link);
}
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index 22025738..537928b5 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -319,13 +319,13 @@ if (!$columns) {
$link = "";
if (!isset($val)) {
$val = "NULL";
- } elseif (ereg('blob|binary', $fields[$key]["type"]) && !is_utf8($val)) { //! download link may be printed even with is_utf8
- $link = htmlspecialchars($SELF . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
- $val = lang('%d byte(s)', strlen($val));
} else {
+ if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
+ $link = htmlspecialchars($SELF . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
+ }
if (!strlen(trim($val, " \t"))) {
$val = " ";
- } elseif (strlen($text_length) && ereg('blob|text', $fields[$key]["type"])) {
+ } elseif (strlen($text_length) && ereg('blob|text', $fields[$key]["type"]) && is_utf8($val)) {
$val = nl2br(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query
} else {
$val = nl2br(htmlspecialchars($val));
diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php
index a9a9c536..8103e43b 100644
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -108,10 +108,14 @@ function adminer_row_descriptions($rows, $foreign_keys) {
}
function adminer_select_val($val, $link, $field) {
- return call_adminer('select_val', ($link
- ? "$val"
- : ($val == "NULL" ? " " : $val)
- ), $val, $link);
+ $return = ($val == "NULL" ? " " : $val);
+ if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
+ $return = lang('%d byte(s)', strlen($val));
+ if (ereg("^(GIF|\xFF\xD8\xFF|\x89\x50\x4E\x47\x0D\x0A\x1A\x0A)", $val)) { // GIF|JPG|PNG, getimagetype() works with filename
+ $return = "
";
+ }
+ }
+ return call_adminer('select_val', ($link ? "$return" : $return), $val, $link);
}
function adminer_message_query($query) {