Page MenuHomePhabricator

PostgreSQL database name regex does not match error message text
Open, Needs TriagePublic

Description

( Related to feature request T187607 )

Current regex in line 102 of mediawiki-1.30.0/includes/installer/PostgresInstaller.php ( /^[a-zA-Z0-9_]+$/ ) allows for letters, numbers, and underscores.
English error message mediawiki-1.30.0/includes/installer/i18n/en.json: "config-invalid-db-name": "Invalid database name \"$1\".\nUse only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens (-)." states that letters, number, underscores, and hypens are valid characters.

Potential solutions to fix this discrepancy would be to

  1. change the error ( along with any translations ) to match what's allowed in the code and remove the part pertaining to hyphens being allowed.

OR

  1. change the regex to match what the error says is allowed ( /^[a-zA-Z0-9_\-]+$/ )

My suggestion is to not only add hyphens to the regex, but also to add periods ( see feature request T187607 ). If developer is already modifying the code to fix one shortcoming, might as well fix another ( although translations and error message will need to be updated if more functionality gets added rather than just shoring up the difference ).