diff --git a/ChangeLog b/ChangeLog
index bbfd4b373..9d7362b3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -63,6 +63,7 @@ danbarry
- bug #1955386 [session] Overriding session.hash_bits_per_character
- [interface] sanitize the table comments in table print view,
thanks to Norman Hippert
+- bug #1910621 [display] part 2: do not display a BINARY content as text
2.11.6.0 (2008-04-29)
- bug #1903724 [interface] Displaying of very large queries in error message
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index c92bdc342..358fdf3a0 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -1210,7 +1210,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// mysql_fetch_array() is MYSQL_BOTH, so we always get
// associative and numeric indices?
- //if (!isset($row[$meta->name])
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = '
NULL | ' . "\n";
} elseif ($row[$i] != '') {
@@ -1285,27 +1284,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// of the fields.
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
- $blobtext = '[BLOB';
- if (!isset($row[$i]) || is_null($row[$i])) {
- $blobtext .= ' - NULL';
- $blob_size = 0;
- } elseif (isset($row[$i])) {
- $blob_size = strlen($row[$i]);
- $display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
- $blobtext .= ' - '. $display_blob_size[0] . ' ' . $display_blob_size[1];
- unset($display_blob_size);
- }
-
- $blobtext .= ']';
- if (strpos($transform_function, 'octetstream')) {
- $blobtext = $row[$i];
- }
- if ($blob_size > 0) {
- $blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta));
- }
- unset($blob_size);
-
+ $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta);
$vertical_display['data'][$row_no][$i] = ' ' . $blobtext . ' | ';
+ unset($blobtext);
} else {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' NULL | ' . "\n";
@@ -1341,12 +1322,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$row[$i] = PMA_printable_bit_value($row[$i], $meta->length);
} elseif (stristr($field_flags, 'BINARY')) {
- $row[$i] = str_replace("\x00", '\0', $row[$i]);
- $row[$i] = str_replace("\x08", '\b', $row[$i]);
- $row[$i] = str_replace("\x0a", '\n', $row[$i]);
- $row[$i] = str_replace("\x0d", '\r', $row[$i]);
- $row[$i] = str_replace("\x1a", '\Z', $row[$i]);
- $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
+ $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta);
}
// loic1: displays all space characters, 4 space
// characters for tabulations and /
@@ -2117,4 +2093,42 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
echo '
';
}
}
+
+/**
+ * Verifies what to do with non-printable contents (binary or BLOB)
+ * in Browse mode.
+ *
+ * @uses is_null()
+ * @uses isset()
+ * @uses strlen()
+ * @uses PMA_formatByteDown()
+ * @uses strpos()
+ * @param string $category BLOB|BINARY
+ * @param string $content the binary content
+ * @param string $transform_function
+ * @param string $transform_options
+ * @param string $default_function
+ * @param object $meta the meta-information about this field
+ * @return mixed string or float
+ */
+function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta) {
+ $result = '[' . $category;
+ if (is_null($content)) {
+ $result .= ' - NULL';
+ $size = 0;
+ } elseif (isset($content)) {
+ $size = strlen($content);
+ $display_size = PMA_formatByteDown($size, 3, 1);
+ $result .= ' - '. $display_size[0] . $display_size[1];
+ }
+
+ $result .= ']';
+ if (strpos($transform_function, 'octetstream')) {
+ $result = $content;
+ }
+ if ($size > 0) {
+ $result = ($default_function != $transform_function ? $transform_function($result, $transform_options, $meta) : $default_function($result, array(), $meta));
+ }
+ return($result);
+}
?>