} 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 = " "; // some content to print a border
} else {
- $val = nl2br(h($val));
+ $val = whitespace(h($val));
if ($types[$key] == 254) {
$val = "<code>$val</code>";
}
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"])
;
}
return htmlspecialchars($string, ENT_QUOTES);
}
+/** Convert text whitespace to HTML
+* @param string
+* @return string
+*/
+function whitespace($string) {
+ return nl2br(preg_replace('~(^| ) ~m', '\\1 ', str_replace("\t", " ", $string)));
+}
+
/** Escape for TD
* @param string
* @return string
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 = " ";
} 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