Issue #3376572 by Lendude, fnalb2, cilefen, longwave: SortPluginBase.php / validateExposeForm: spelling mistake in character class

merge-requests/4505/head
Lauri Eskola 2023-07-29 16:33:50 +03:00
parent d55e9171e5
commit edf79f6705
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
2 changed files with 5 additions and 2 deletions

View File

@ -230,7 +230,7 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
'expose',
'field_identifier',
]);
if (!preg_match('/^[a-zA-z][a-zA-Z0-9_~.\-]*$/', $field_identifier)) {
if (!preg_match('/^[a-zA-Z][a-zA-Z0-9_~.\-]*$/', $field_identifier)) {
$form_state->setErrorByName('expose][field_identifier', $this->t('This identifier has illegal characters.'));
return;
}

View File

@ -150,10 +150,13 @@ class ExposedFormUITest extends UITestBase {
$this->submitForm($edit, 'Apply');
$this->assertSession()->pageTextContains('Sort field identifier field is required.');
// Try with an invalid identifier.
// Try with an invalid identifiers.
$edit['options[expose][field_identifier]'] = 'abc&! ###08.';
$this->submitForm($edit, 'Apply');
$this->assertSession()->pageTextContains('This identifier has illegal characters.');
$edit['options[expose][field_identifier]'] = '^abcde';
$this->submitForm($edit, 'Apply');
$this->assertSession()->pageTextContains('This identifier has illegal characters.');
// Use a valid identifier.
$edit['options[expose][field_identifier]'] = $this->randomMachineName() . '_-~.';