IP transformed to binary were not understood anymore

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2019-11-03 20:47:42 +01:00
parent 164c15854d
commit f4e786d9a9

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Transformations\Output;
use PhpMyAdmin\Plugins\TransformationsPlugin;
use function hex2bin;
/**
* Handles the binary to IPv4/IPv6 transformation for text plain
@ -45,15 +46,18 @@ class Text_Plain_Binarytoip extends TransformationsPlugin
*/
public function applyTransformation($buffer, array $options = array(), $meta = '')
{
$length = strlen($buffer);
if ($length == 4 || $length == 16) {
$val = @inet_ntop(pack('A' . $length, $buffer));
if ($val !== false) {
return $val;
}
if (0 !== strpos($buffer, '0x')) {
return $buffer;
}
return $buffer;
$ipHex = substr($buffer, 2);
$ipBin = hex2bin($ipHex);
if (false === $ipBin) {
return $buffer;
}
return @inet_ntop($ipBin);
}