]> git.joonet.de Git - adminer.git/commitdiff
Display whitespace in texts (bug #2858042)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 14 Sep 2009 19:39:37 +0000 (19:39 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 14 Sep 2009 19:39:37 +0000 (19:39 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1110 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php

index 990fde8642756c56cc0ea9eae13fff310efc863a..907847f4412f27dfd7136dbe2a9e4a392323f0b8 100644 (file)
@@ -53,10 +53,10 @@ function select($result, $dbh2 = null) {
                                } else {
                                        if ($blobs[$key] && !is_utf8($val)) {
                                                $val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
-                                       } elseif (!strlen(trim($val, " \t"))) {
+                                       } elseif (!strlen($val)) {
                                                $val = "&nbsp;"; // some content to print a border
                                        } else {
-                                               $val = nl2br(h($val));
+                                               $val = whitespace(h($val));
                                                if ($types[$key] == 254) {
                                                        $val = "<code>$val</code>";
                                                }
@@ -124,7 +124,7 @@ function process_field($field, $type_field) {
        global $dbh;
        return idf_escape($field["field"]) . process_type($type_field)
                . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
-               . (!isset($field["default"]) || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $field["default"]) ? $field["default"] : $dbh->quote($field["default"])))
+               . (!$field["has_default"] || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $field["default"]) ? $field["default"] : $dbh->quote($field["default"])))
                . " COMMENT " . $dbh->quote($field["comment"])
        ;
 }
index b66462bbabf16483db321b24a1a8c8f82f18212b..76bba2a943bc94ad94b573307a308a930456b508 100644 (file)
@@ -43,6 +43,14 @@ function h($string) {
        return htmlspecialchars($string, ENT_QUOTES);
 }
 
+/** Convert text whitespace to HTML
+* @param string
+* @return string
+*/
+function whitespace($string) {
+       return nl2br(preg_replace('~(^| ) ~m', '\\1&nbsp;', str_replace("\t", "    ", $string)));
+}
+
 /** Escape for TD
 * @param string
 * @return string
index 93b5c27ac9977098c0696f8bea127eab3ea594be..bf6e2e9362e16ffd789694c5ce25744883f38a60 100644 (file)
@@ -219,12 +219,12 @@ if (!$columns) {
                                                        if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
                                                                $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . '&') . $unique_idf;
                                                        }
-                                                       if (!strlen(trim($val, " \t"))) {
+                                                       if (!strlen($val)) {
                                                                $val = "&nbsp;";
                                                        } 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
+                                                               $val = whitespace(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query
                                                        } else {
-                                                               $val = nl2br(h($val));
+                                                               $val = whitespace(h($val));
                                                        }
                                                        
                                                        if (!$link) { // link related items