diff --git a/ChangeLog b/ChangeLog index 92ec68ce6..807fec0c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,7 +17,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA - [interface] sanitize the table comments in table print view, thanks to Norman Hippert - bug #1939031 Auto_Increment selected for TimeStamp by Default - +- 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 0921a2823..983be700d 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1233,7 +1233,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // n u m e r i c if ($meta->numeric == 1) { - // lem9: if two fields have the same name (this is possible // with self-join queries, for example), using $meta->name // will show both fields NULL even if only one is NULL, @@ -1244,7 +1243,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] != '') { @@ -1308,27 +1306,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"; @@ -1364,12 +1344,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 / @@ -2128,4 +2103,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); +} ?>