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;
}
// 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;
}
}
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),