Skip to content
Extraits de code Groupes Projets
Valider 259fc6d7 rédigé par Jan Wroniszewski's avatar Jan Wroniszewski Validation de Matthieu Aubry
Parcourir les fichiers

#10547 Bad regexp in DbHelper.php (#10688)

parent dda85d6d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -198,7 +198,7 @@ class DbHelper
*/
public static function isValidDbname($dbname)
{
return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z_0-9.-\+]*))$/D', $dbname));
return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z0-9\_\.\-\+]*))$/D', $dbname));
}
}
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Unit;
use Piwik\DbHelper;
/**
* Class DbHelperTest
* @package Piwik\Tests\Unit
* @group Core
* @group Core_Unit
*/
class DbHelperTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getVariousDbNames
* @param string $dbName
* @param bool $expectation
*/
public function testCorrectNames($dbName, $expectation)
{
$this->assertSame(DbHelper::isValidDbname($dbName), $expectation);
}
public function getVariousDbNames()
{
return array(
'simpleDbName' => array(
'dbName' => 'FirstPiwikDb',
'expectation' => true
),
'containsNumbers' => array(
'dbName' => 'FirstPiw1kDb',
'expectation' => true
),
'startsWithNumber' => array(
'dbName' => '1stPiwikDb',
'expectation' => true
),
'containsAllowedSpecialCharacters' => array(
'dbName' => 'MyPiwikDb-with.More+compleX_N4M3',
'expectation' => true
),
'containsSpace' => array(
'dbName' => '1st PiwikDb',
'expectation' => false
),
'startWithNonAlphaNumericSign' => array(
'dbName' => ';FirstPiwikDb',
'expectation' => false
),
);
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter