Could you write tests for this change? These files are actually apart of the ACITree refactoring patch. If this patch was already in master the task of adding tests would be much easier.
I have reviewed your code and looks good to me. Can we change the message from "The database name is inappropriate" to some meaningful message, so that user should know why it is inappropriate. If user will be able to create database with "=" in name then why Backup, Maintenance and Restore fails.
Just curious, as I understand the problem, we're not able to able to run pg_dump/pg_restore/psql against the database, which contains '=' in the name.
Can we use PGDATABASE environment variable for them?
Of course - this tools may still fail when special characters (e.g. '=') exists in the name of the database objects (e.g. schema, table, etc).