Make sure db prefix / suffix is consistently applied

Modifies the db_get_table() and plugin_table() functions to ensure that
we build a correct table name based on the user's config settings, e.g.

- trim leading/trailing whitespace
- do not add underscores if already present

Fixes #17355, regression issue introduced by commit
5a84e9db76162e378b9a1b0dea129d1f7ce127e9 where plugin_table() no longer
inserts an underscore after $g_db_table_plugin_prefix