From 07c4a73eb0734b704339666c70d22b572424bf13 Mon Sep 17 00:00:00 2001 From: Corey Buckley Date: Fri, 24 Jan 2020 16:56:37 -0500 Subject: [PATCH 1/3] Changes trim to regex in convertBitDefaultValue Fixes the issue described in #15831. Signed-off-by: Corey Buckley --- libraries/classes/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 7b97adbb7b..bc1436e64d 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -2858,7 +2858,7 @@ class Util */ public static function convertBitDefaultValue($bit_default_value) { - return rtrim(ltrim(htmlspecialchars_decode($bit_default_value, ENT_QUOTES), "b'"), "'"); + return preg_replace("/^b'(.*?)'?$/s", '$1', htmlspecialchars_decode($bit_default_value, ENT_QUOTES), 1); } /** From fcb451d70bdc319bf72ef11a9d3e17c30fbf9bdd Mon Sep 17 00:00:00 2001 From: corey buckley Date: Sat, 25 Jan 2020 13:49:26 -0500 Subject: [PATCH 2/3] Tests added for convertBitDefaultValue. Consider valid database names with single quotes. Change regex to only replace if digits between b'..' Signed-off-by: Corey Buckley --- libraries/classes/Util.php | 2 +- test/classes/UtilTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index bc1436e64d..7cdc9d45de 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -2858,7 +2858,7 @@ class Util */ public static function convertBitDefaultValue($bit_default_value) { - return preg_replace("/^b'(.*?)'?$/s", '$1', htmlspecialchars_decode($bit_default_value, ENT_QUOTES), 1); + return preg_replace("/^b'(\d*)'?$/", '$1', htmlspecialchars_decode($bit_default_value, ENT_QUOTES), 1); } /** diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 9a59e97d8f..1cbc942a86 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -483,6 +483,22 @@ class UtilTest extends PmaTestCase "b'010111010'", "010111010", ], + "database name starting with b" => [ + "big database", + "big database", + ], + "database name containing b'" => [ + "a b'ig database", + "a b'ig database", + ], + "database name in single quotes" => [ + "'a*database*name'", + "'a*database*name'", + ], + "database name with multiple b'" => [ + "b'ens datab'ase'", + "b'ens datab'ase'", + ], ]; } From ab0f60c73e7a526c4e158d6937248c1234944aa3 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 25 Jan 2020 21:04:45 +0100 Subject: [PATCH 3/3] Add ChangeLog entry for #15831 Signed-off-by: William Desportes --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 50dde311a6..5529ccf695 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ phpMyAdmin - ChangeLog - issue Fix php notice "Trying to access array offset on value of type bool" on Designer - issue #13326 Added integer validations on search page - issue #15200 Fixed server-side HTTPS detection misses support for Forwarded HTTP Extension (RFC 7239) +- issue #15831 Fixed DB names starting with "b" being cut off in