escape usernames & passwords when setting the DATABASE_URL
This commit is contained in:
1 parent
78c9b0f4dc
commit
b27e5ed1f5
1 file changed
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
require 'cgi'
|
||||||
require_relative 'error'
|
require_relative 'error'
|
||||||
require_relative 'version'
|
require_relative 'version'
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ module Postal
|
|||||||
|
|
||||||
def self.database_url
|
def self.database_url
|
||||||
if config.main_db
|
if config.main_db
|
||||||
"mysql2://#{config.main_db.username}:#{config.main_db.password}@#{config.main_db.host}:#{config.main_db.port}/#{config.main_db.database}?encoding=#{config.main_db.encoding || 'utf8mb4'}"
|
"mysql2://#{CGI.escape(config.main_db.username.to_s)}:#{CGI.escape(config.main_db.password.to_s)}@#{config.main_db.host}:#{config.main_db.port}/#{config.main_db.database}?reconnect=true&encoding=#{config.main_db.encoding || 'utf8mb4'}"
|
||||||
else
|
else
|
||||||
"mysql2://root@localhost/postal"
|
"mysql2://root@localhost/postal"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user