diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 33840bc64..8afbfae25 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -586,6 +586,11 @@ function PMA_DBI_field_name($result, $i) * @uses MYSQLI_UNIQUE_KEY_FLAG * @uses MYSQLI_PRI_KEY_FLAG * @uses MYSQLI_NOT_NULL_FLAG + * @uses MYSQLI_TYPE_BLOB + * @uses MYSQLI_TYPE_MEDIUM_BLOB + * @uses MYSQLI_TYPE_LONG_BLOB + * @uses MYSQLI_TYPE_VAR_STRING + * @uses MYSQLI_TYPE_STRING * @uses mysqli_fetch_field_direct() * @param object mysqli result $result * @param integer $i field @@ -598,6 +603,7 @@ function PMA_DBI_field_flags($result, $i) define('MYSQLI_ENUM_FLAG', 256); // see MySQL source include/mysql_com.h } $f = mysqli_fetch_field_direct($result, $i); + $type = $f->type; $charsetnr = $f->charsetnr; $f = $f->flags; $flags = ''; @@ -609,10 +615,12 @@ function PMA_DBI_field_flags($result, $i) if ($f & MYSQLI_AUTO_INCREMENT_FLAG) { $flags .= 'auto_increment ';} if ($f & MYSQLI_ENUM_FLAG) { $flags .= 'enum ';} // See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html: - // to determine the data type, we should not use MYSQLI_BINARY_FLAG - // the binary flag but instead the charsetnr member of the MYSQL_FIELD - // structure. Unfortunately there is no equivalent in the mysql extension. - if (63 == $charsetnr) { $flags .= 'binary ';} + // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG + // but instead the charsetnr member of the MYSQL_FIELD + // structure. Watch out: some types like DATE returns 63 in charsetnr + // so we have to check also the type. + // Unfortunately there is no equivalent in the mysql extension. + if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB || $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB || $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING) && 63 == $charsetnr) { $flags .= 'binary ';} if ($f & MYSQLI_ZEROFILL_FLAG) { $flags .= 'zerofill ';} if ($f & MYSQLI_UNSIGNED_FLAG) { $flags .= 'unsigned ';} if ($f & MYSQLI_BLOB_FLAG) { $flags .= 'blob ';} diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 358fdf3a0..85daeb6c0 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1321,7 +1321,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { $field_flags = PMA_DBI_field_flags($dt_result, $i); if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) { $row[$i] = PMA_printable_bit_value($row[$i], $meta->length); - } elseif (stristr($field_flags, 'BINARY')) { + } elseif (stristr($field_flags, 'BINARY') && $meta->type == 'string') { $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta); } // loic1: displays all space characters, 4 space @@ -2103,6 +2103,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) { * @uses strlen() * @uses PMA_formatByteDown() * @uses strpos() + * @uses str_replace() * @param string $category BLOB|BINARY * @param string $content the binary content * @param string $transform_function @@ -2121,13 +2122,25 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct $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)); + if ($default_function != $transform_function) { + $result = $transform_function($result, $transform_options, $meta); + } else { + $result = $default_function($result, array(), $meta); + if (stristr($meta->type, 'BLOB') && $GLOBALS['cfg']['ShowBlob'] == true) { + // in this case, restart from the original $content + $result = str_replace("\x00", '\0', $content); + $result = str_replace("\x08", '\b', $result); + $result = str_replace("\x0a", '\n', $result); + $result = str_replace("\x0d", '\r', $result); + $result = str_replace("\x1a", '\Z', $result); + } + } } return($result); }