diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 2cb57194..8a0f8e1e 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -109,10 +109,12 @@ function adminer_row_descriptions($rows, $foreign_keys) { /** Value printed in select table * @param string escaped value to print * @param string link to foreign key +* @param array single field returned from fields() * @return string */ -function adminer_select_val($val, $link) { - return call_adminer('select_val', ($link ? "$val" : $val), $val, $link); +function adminer_select_val($val, $link, $field) { + $return = ($field["type"] == "char" ? "$val" : $val); + return call_adminer('select_val', ($link ? "$return" : $return), $val, $link); } /** Query printed after execution in the message diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 3dd64e16..0f6d4dab 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -364,11 +364,11 @@ function email_header($header) { return "=?UTF-8?B?" . base64_encode($header) . "?="; //! split long lines } -function call_adminer($method, $default, $arg1 = null, $arg2 = null) { +function call_adminer($method, $default, $arg1 = null, $arg2 = null, $arg3 = null) { // maintains original method name in minification if (method_exists('Adminer', $method)) { // user defined class // can use func_get_args() and call_user_func_array() - return Adminer::$method($arg1, $arg2); + return Adminer::$method($arg1, $arg2, $arg3); } return $default; //! $default is evaluated even if not neccessary } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index d4622e58..22025738 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -312,7 +312,7 @@ if (!$columns) { $unique_idf = implode('&', unique_idf($rows[$n], $indexes)); //! don't use aggregation functions echo '' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' ' . lang('edit') . ''); foreach ($row as $key => $val) { - if (strlen($names[$key])) { + if (isset($names[$key])) { if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) { $email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages } @@ -329,9 +329,6 @@ if (!$columns) { $val = nl2br(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query } else { $val = nl2br(htmlspecialchars($val)); - if ($fields[$key]["type"] == "char") { - $val = "$val"; - } } // link related items @@ -348,7 +345,7 @@ if (!$columns) { if (!$link && is_email($val)) { $link = "mailto:$val"; } - $val = adminer_select_val($val, $link); + $val = adminer_select_val($val, $link, $fields[$key]); echo "$val"; } } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 063791d4..a9a9c536 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -107,10 +107,10 @@ function adminer_row_descriptions($rows, $foreign_keys) { return call_adminer('row_descriptions', $return, $rows, $foreign_keys); } -function adminer_select_val($val, $link) { - return call_adminer('select_val', ($link ? - "$val" : - ($val == "NULL" ? " " : preg_replace('~^(.*)$~', '\\1', $val)) +function adminer_select_val($val, $link, $field) { + return call_adminer('select_val', ($link + ? "$val" + : ($val == "NULL" ? " " : $val) ), $val, $link); }