From: Mattias Michaux Date: Sun, 8 May 2016 08:02:25 +0000 (+0200) Subject: Fixed regression when search for location types. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=951ba594ce818ca25486c58e2f25500fcdd2a86c;p=civicrm-core.git Fixed regression when search for location types. --- diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index 3251d26bbe..efb64eb858 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -100,11 +100,12 @@ class CRM_Utils_Rule { return FALSE; } - // Ensure it only contains valid characters (alphanumeric and underscores). + // Ensure it only contains valid characters (alphanumeric, hyphens and + // underscores). // // MySQL permits column names that don't match this (eg containing spaces), // but CiviCRM won't create those ... - if (!preg_match('/^\w{1,64}(\.\w{1,64})?$/i', $str)) { + if (!preg_match('/^[\w-]{1,64}(\.[\w-]{1,64})?$/i', $str)) { return FALSE; } @@ -138,7 +139,7 @@ class CRM_Utils_Rule { // at all, so we split and loop over. $parts = explode(',', $str); foreach ($parts as $part) { - if (!preg_match('/^((\w{1,64})((\.)(\w{1,64}))?( (asc|desc))?)$/i', trim($part))) { + if (!preg_match('/^(([\w-]{1,64})((\.)([\w-]{1,64}))?( (asc|desc))?)$/i', trim($part))) { return FALSE; } } diff --git a/tests/phpunit/CRM/Utils/TypeTest.php b/tests/phpunit/CRM/Utils/TypeTest.php index 4e51944f31..793a5334bc 100644 --- a/tests/phpunit/CRM/Utils/TypeTest.php +++ b/tests/phpunit/CRM/Utils/TypeTest.php @@ -40,7 +40,7 @@ class CRM_Utils_TypeTest extends CiviUnitTestCase { array('civicrm_column_name', 'MysqlColumnName', 'civicrm_column_name'), array('table.civicrm_column_name', 'MysqlColumnName', 'table.civicrm_column_name'), array('table.civicrm_column_name.toomanydots', 'MysqlColumnName', NULL), - array('invalid-column-name', 'MysqlColumnName', NULL), + array('Home-street_address', 'MysqlColumnName', 'Home-street_address'), array('column_name, sleep(5)', 'MysqlColumnName', NULL), array(str_repeat('a', 64), 'MysqlColumnName', str_repeat('a', 64)), array(str_repeat('a', 65), 'MysqlColumnName', NULL),