Don't print query in edit

This commit is contained in:
Jakub Vrana 2014-01-10 21:32:07 -08:00
parent dbf5eede9d
commit 2ecff21280
7 changed files with 19 additions and 19 deletions

View file

@ -220,12 +220,13 @@ username.form['auth[driver]'].onchange();
* @param string HTML-escaped value to print * @param string HTML-escaped value to print
* @param string link to foreign key * @param string link to foreign key
* @param array single field returned from fields() * @param array single field returned from fields()
* @param array original value before applying editVal() and escaping
* @return string * @return string
*/ */
function selectVal($val, $link, $field) { function selectVal($val, $link, $field, $original) {
$return = ($val === null ? "<i>NULL</i>" : (preg_match("~char|binary~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "<code>$val</code>" : $val)); $return = ($val === null ? "<i>NULL</i>" : (preg_match("~char|binary~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "<code>$val</code>" : $val));
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && !is_utf8($val)) { if (preg_match('~blob|bytea|raw|file~', $field["type"]) && !is_utf8($val)) {
$return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES))); $return = lang('%d byte(s)', strlen($original));
} }
return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return); return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return);
} }

View file

@ -1041,18 +1041,17 @@ function select_value($val, $link, $field, $text_length) {
); );
} }
} }
$val = $adminer->editVal($val, $field); $return = $adminer->editVal($val, $field);
if ($val !== null) { if ($return !== null) {
if ($val === "") { // === - may be int if ($return === "") { // === - may be int
$val = "&nbsp;"; $return = "&nbsp;";
} elseif ($text_length != "" && is_shortable($field)) { } elseif ($text_length != "" && is_shortable($field) && is_utf8($return)) {
$val = shorten_utf8($val, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network $return = shorten_utf8($return, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network
} else { } else {
$val = h($val); $return = h($return);
} }
} }
$val = $adminer->selectVal($val, $link, $field); return $adminer->selectVal($return, $link, $field, $val);
return $val;
} }
/** Check whether the string is e-mail address /** Check whether the string is e-mail address

View file

@ -1,11 +1,11 @@
Adminer 4.0.1-dev: Adminer 4.0.1-dev:
Fix compiled version of Elasticsearch
Don't use type=number if a SQL function is used Don't use type=number if a SQL function is used
Disable highlighting in textareas with long texts Disable highlighting in textareas with long texts
Don't autofocus SQL textarea in Firefox Don't autofocus SQL textarea in Firefox
Don't link NULL foreign key values Don't link NULL foreign key values
Fix displaying images in Editor, bug since Adminer 3.6.0
MongoDB: Count tables, display ObjectIds, sort, limit, offset, count rows MongoDB: Count tables, display ObjectIds, sort, limit, offset, count rows
Elasticsearch: Create and drop DB, drop table Elasticsearch: Fix compiled version, create and drop DB, drop table
Adminer 4.0.0 (released 2014-01-08): Adminer 4.0.0 (released 2014-01-08):
Driver for SimpleDB, MongoDB and Elasticsearch Driver for SimpleDB, MongoDB and Elasticsearch

View file

@ -170,12 +170,12 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
function selectLink($val, $field) { function selectLink($val, $field) {
} }
function selectVal($val, $link, $field) { function selectVal($val, $link, $field, $original) {
$return = ($val === null ? "&nbsp;" : $val); $return = ($val === null ? "&nbsp;" : $val);
$link = h($link); $link = h($link);
if (preg_match('~blob|bytea~', $field["type"]) && !is_utf8($val)) { if (preg_match('~blob|bytea~', $field["type"]) && !is_utf8($val)) {
$return = lang('%d byte(s)', strlen($val)); $return = lang('%d byte(s)', strlen($original));
if (preg_match("~^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)~", $val)) { // GIF|JPG|PNG, getimagetype() works with filename 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'>"; $return = "<img src='$link' alt='$return'>";
} }
} }

View file

@ -44,7 +44,7 @@ class AdminerFileUpload {
} }
} }
function selectVal($val, &$link, $field) { function selectVal($val, &$link, $field, $original) {
if ($val != "&nbsp;" && preg_match('~(.*)_path$~', $field["field"], $regs)) { if ($val != "&nbsp;" && preg_match('~(.*)_path$~', $field["field"], $regs)) {
$link = "$this->displayPath$_GET[select]/$regs[1]-$val"; $link = "$this->displayPath$_GET[select]/$regs[1]-$val";
} }

View file

@ -46,7 +46,7 @@ tinyMCE.init({
<?php <?php
} }
function selectVal(&$val, $link, $field) { function selectVal(&$val, $link, $field, $original) {
if (preg_match("~_html~", $field["field"]) && $val != '&nbsp;') { if (preg_match("~_html~", $field["field"]) && $val != '&nbsp;') {
$shortened = (substr($val, -10) == "<i>...</i>"); $shortened = (substr($val, -10) == "<i>...</i>");
if ($shortened) { if ($shortened) {

View file

@ -26,7 +26,7 @@ class AdminerWymeditor {
} }
} }
function selectVal(&$val, $link, $field) { function selectVal(&$val, $link, $field, $original) {
// copied from tinymce.php // copied from tinymce.php
if (preg_match("~_html~", $field["field"]) && $val != '&nbsp;') { if (preg_match("~_html~", $field["field"]) && $val != '&nbsp;') {
$shortened = (substr($val, -10) == "<i>...</i>"); $shortened = (substr($val, -10) == "<i>...</i>");