lib/koine/db_bkp/mysql/dump.rb in koine-db_bkp-0.1.2 vs lib/koine/db_bkp/mysql/dump.rb in koine-db_bkp-0.1.3

- old
+ new

@@ -15,22 +15,26 @@ end def to_sql_file(file) parts = ['mysqldump'] - parts.push("-h #{@hostname}") if @hostname - parts.push("-u #{@username}") if @username - parts.push("-p#{@password}") if @password + parts.push("-h #{escape(@hostname)}") if @hostname + parts.push("-u #{escape(@username)}") if @username + parts.push("-p#{escape(@password)}") if @password parts.push(@database) file = FileName.new(file) parts.push("> #{file}") @cli.execute(parts.join(' ')) end private + + def escape(string) + Shellwords.escape(string) + end def normalize_config(config) config = config.reject { |_k, v| ['', nil].include?(v) } merge_url(symbolize_keys(config)) end