@@ -27,21 +27,15 @@ trait ValidatesDatabaseParameters
2727 * Since non-password parameters don't need to use as many special characters, we use
2828 * a stricter allowlist here.
2929 */
30- protected function allowedParameterCharacters (): string
31- {
32- return 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- ' ;
33- }
30+ public static string $ allowedParameterCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- ' ;
3431
3532 /**
3633 * Characters allowed in database user passwords.
3734 *
3835 * The allowlist for passwords is less strict than for other parameters
3936 * because it's more common to use more special characters in passwords.
4037 */
41- protected function allowedPasswordCharacters (): string
42- {
43- return ' !#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~ ' ;
44- }
38+ public static string $ allowedPasswordCharacters = ' !#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~ ' ;
4539
4640 /**
4741 * Ensure that parameters (database names, usernames, etc.)
@@ -58,7 +52,7 @@ protected function validateParameter(string|array|null $parameters, string|null
5852 throw new InvalidArgumentException ('Parameter cannot be null. ' );
5953 }
6054
61- $ allowedCharacters ??= $ this -> allowedParameterCharacters () ;
55+ $ allowedCharacters ??= static :: $ allowedParameterCharacters ;
6256
6357 foreach (Arr::wrap ($ parameters ) as $ parameter ) {
6458 if (is_null ($ parameter )) {
@@ -93,6 +87,6 @@ protected function validateParameter(string|array|null $parameters, string|null
9387 */
9488 protected function validatePassword (string |null $ password ): void
9589 {
96- $ this ->validateParameter ($ password , allowedCharacters: $ this -> allowedPasswordCharacters () );
90+ $ this ->validateParameter ($ password , allowedCharacters: static :: $ allowedPasswordCharacters );
9791 }
9892}
0 commit comments