Handle multiple :p while sanitizing MySQL hosts

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
Deven Bansod 2016-11-08 10:14:20 +05:30
parent 337b38044d
commit 6703597772
2 changed files with 4 additions and 3 deletions

View File

@ -891,7 +891,7 @@ if (! function_exists('hash_hmac')) {
/**
* Sanitizes MySQL hostname
*
* * strips p: prefix
* * strips p: prefix(es)
*
* @param string $name User given hostname
*
@ -899,8 +899,8 @@ if (! function_exists('hash_hmac')) {
*/
function PMA_sanitizeMySQLHost($name)
{
if (strtolower(substr($name, 0, 2)) == 'p:') {
return substr($name, 2);
while (strtolower(substr($name, 0, 2)) == 'p:') {
$name = substr($name, 2);
}
return $name;

View File

@ -40,6 +40,7 @@ class PMA_sanitizeMySQLHost_test extends PHPUnit_Framework_TestCase
{
return array(
array('p:foo.bar', 'foo.bar'),
array('p:p:foo.bar', 'foo.bar'),
array('bar.baz', 'bar.baz'),
array('P:example.com', 'example.com'),
);