diff --git a/ChangeLog b/ChangeLog index 175782dcce..ae3d15ce98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ phpMyAdmin - ChangeLog + rfe #1421 [auth] Add retry button on connection failure with config auth + rfe #1422 [interface] Provide feedback if no columns selected for multi-submit - bug #3799 [interface] Incorrect select field change on ctrl key navigation in Firefox +- bug #3885 [browse] display_binary_as_hex option causes unexpected behavior 4.0.0.0 (not yet released) + Patch #3481047 for rfe #3480477 Insert as new row enhancement diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index d04dcfd5d2..a8a2b4c78e 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -3760,23 +3760,13 @@ class PMA_DisplayResults ); } else { - // Prepare in Well Known Binary(WKB) format. + // Prepare in Well Known Binary (WKB) format. if ($_SESSION['tmp_user_values']['display_binary']) { $where_comparison = ' = ' . $column; - if ($_SESSION['tmp_user_values']['display_binary_as_hex'] - && PMA_Util::containsNonPrintableAscii($column) - ) { - $wkbval = PMA_substr(bin2hex($column), 8); - } else { - $wkbval = htmlspecialchars( - PMA_Util::replaceBinaryContents( - $column - ) - ); - } + $wkbval = $this->_displayBinaryAsPrintable($column, 'binary', 8); if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) @@ -3894,17 +3884,7 @@ class PMA_DisplayResults // user asked to see the real contents of BINARY // fields - if ($_SESSION['tmp_user_values']['display_binary_as_hex'] - && PMA_Util::containsNonPrintableAscii($column) - ) { - $column = bin2hex($column); - } else { - $column = htmlspecialchars( - PMA_Util::replaceBinaryContents( - $column - ) - ); - } + $column = $this->_displayBinaryAsPrintable($column, 'binary'); } else { // we show the BINARY message and field's size @@ -5429,11 +5409,7 @@ class PMA_DisplayResults && $_SESSION['tmp_user_values']['display_blob'] ) { // in this case, restart from the original $content - $result = htmlspecialchars( - PMA_Util::replaceBinaryContents( - $content - ) - ); + $result = $this->_displayBinaryAsPrintable($content, 'blob'); } /* Create link to download */ @@ -5943,5 +5919,44 @@ class PMA_DisplayResults return $buffer; } + /** + * Display binary fields as hex string for PHP <5.4, + * otherwise escape the contents if it may be displayed as hex + * + * @param string $content String to parse + * @param string $binary_or_blob 'binary' or 'blob' + * @param int $hexlength optional, get substring + * + * @return Displayable version of the binary string + * + * @access private + * + * @see _getDataCellForGeometryColumns + * _getDataCellForNonNumericAndNonBlobColumns + * _handleNonPrintableContents + */ + private function _displayBinaryAsPrintable( + $content, $binary_or_blob, $hexlength = null + ) { + if (PMA_PHP_INT_VERSION < 50400 + || ($binary_or_blob === 'binary' + && $_SESSION['tmp_user_values']['display_binary_as_hex'] + && PMA_Util::containsNonPrintableAscii($content) + ) + ) { + $content = bin2hex($content); + if ($hexlength !== null) { + $content = PMA_substr($content, $hexlength); + } + } else { + $content = htmlspecialchars( + PMA_Util::replaceBinaryContents( + $content + ), + ENT_SUBSTITUTE + ); + } + return $content; + } } ?>