Commit f9b66aecddb248dcd501419e0ee94fd69fab4de3
1 parent
ad41430c
Exists in
master
and in
4 other branches
Revert "More escaping"
This reverts commit c46eaca91247ccf8e6fb3b691dad028e1b084ae3.
Showing
5 changed files
with
17 additions
and
19 deletions
Show diff stats
lib/backup/database.rb
1 | require 'yaml' | 1 | require 'yaml' |
2 | -require 'shellwords' | ||
3 | 2 | ||
4 | module Backup | 3 | module Backup |
5 | class Database | 4 | class Database |
@@ -14,20 +13,20 @@ module Backup | @@ -14,20 +13,20 @@ module Backup | ||
14 | def dump | 13 | def dump |
15 | case config["adapter"] | 14 | case config["adapter"] |
16 | when /^mysql/ then | 15 | when /^mysql/ then |
17 | - system("mysqldump #{mysql_args} #{Shellwords.shellescape(config['database'])} > #{Shellwords.shellescape(db_file_name)}") | 16 | + system("mysqldump #{mysql_args} #{config['database']} > #{db_file_name}") |
18 | when "postgresql" then | 17 | when "postgresql" then |
19 | pg_env | 18 | pg_env |
20 | - system("pg_dump #{Shellwords.shellescape(config['database'])} > #{db_file_name}") | 19 | + system("pg_dump #{config['database']} > #{db_file_name}") |
21 | end | 20 | end |
22 | end | 21 | end |
23 | 22 | ||
24 | def restore | 23 | def restore |
25 | case config["adapter"] | 24 | case config["adapter"] |
26 | when /^mysql/ then | 25 | when /^mysql/ then |
27 | - system("mysql #{mysql_args} #{Shellwords.shellescape(config['database'])} < #{db_file_name}") | 26 | + system("mysql #{mysql_args} #{config['database']} < #{db_file_name}") |
28 | when "postgresql" then | 27 | when "postgresql" then |
29 | pg_env | 28 | pg_env |
30 | - system("psql #{Shellwords.shellescape(config['database'])} -f #{Shellwords.shellescape(db_file_name)}") | 29 | + system("psql #{config['database']} -f #{db_file_name}") |
31 | end | 30 | end |
32 | end | 31 | end |
33 | 32 | ||
@@ -46,7 +45,7 @@ module Backup | @@ -46,7 +45,7 @@ module Backup | ||
46 | 'encoding' => '--default-character-set', | 45 | 'encoding' => '--default-character-set', |
47 | 'password' => '--password' | 46 | 'password' => '--password' |
48 | } | 47 | } |
49 | - args.map { |opt, arg| "#{arg}=#{Shellwords.shellescape(config[opt])}" if config[opt] }.compact.join(' ') | 48 | + args.map { |opt, arg| "#{arg}='#{config[opt]}'" if config[opt] }.compact.join(' ') |
50 | end | 49 | end |
51 | 50 | ||
52 | def pg_env | 51 | def pg_env |
lib/backup/repository.rb
1 | require 'yaml' | 1 | require 'yaml' |
2 | -require 'shellwords' | ||
3 | 2 | ||
4 | module Backup | 3 | module Backup |
5 | class Repository | 4 | class Repository |
@@ -19,7 +18,7 @@ module Backup | @@ -19,7 +18,7 @@ module Backup | ||
19 | # Create namespace dir if missing | 18 | # Create namespace dir if missing |
20 | FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace | 19 | FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace |
21 | 20 | ||
22 | - if system("cd #{Shellwords.shellescape(path_to_repo(project))} > /dev/null 2>&1 && git bundle create #{Shellwords.shellescape(path_to_bundle(project))} --all > /dev/null 2>&1") | 21 | + if system("cd #{path_to_repo(project)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(project)} --all > /dev/null 2>&1") |
23 | puts "[DONE]".green | 22 | puts "[DONE]".green |
24 | else | 23 | else |
25 | puts "[FAILED]".red | 24 | puts "[FAILED]".red |
@@ -31,7 +30,7 @@ module Backup | @@ -31,7 +30,7 @@ module Backup | ||
31 | print " * #{wiki.path_with_namespace} ... " | 30 | print " * #{wiki.path_with_namespace} ... " |
32 | if wiki.empty? | 31 | if wiki.empty? |
33 | puts " [SKIPPED]".cyan | 32 | puts " [SKIPPED]".cyan |
34 | - elsif system("cd #{Shellwords.shellescape(path_to_repo(wiki))} > /dev/null 2>&1 && git bundle create #{Shellwords.shellescape(path_to_bundle(wiki))} --all > /dev/null 2>&1") | 33 | + elsif system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1") |
35 | puts " [DONE]".green | 34 | puts " [DONE]".green |
36 | else | 35 | else |
37 | puts " [FAILED]".red | 36 | puts " [FAILED]".red |
@@ -54,7 +53,7 @@ module Backup | @@ -54,7 +53,7 @@ module Backup | ||
54 | 53 | ||
55 | project.namespace.ensure_dir_exist if project.namespace | 54 | project.namespace.ensure_dir_exist if project.namespace |
56 | 55 | ||
57 | - if system("git clone --bare #{Shellwords.shellescape(path_to_bundle(project))} #{Shellwords.shellescape(path_to_repo(project))} > /dev/null 2>&1") | 56 | + if system("git clone --bare #{path_to_bundle(project)} #{path_to_repo(project)} > /dev/null 2>&1") |
58 | puts "[DONE]".green | 57 | puts "[DONE]".green |
59 | else | 58 | else |
60 | puts "[FAILED]".red | 59 | puts "[FAILED]".red |
@@ -64,7 +63,7 @@ module Backup | @@ -64,7 +63,7 @@ module Backup | ||
64 | 63 | ||
65 | if File.exists?(path_to_bundle(wiki)) | 64 | if File.exists?(path_to_bundle(wiki)) |
66 | print " * #{wiki.path_with_namespace} ... " | 65 | print " * #{wiki.path_with_namespace} ... " |
67 | - if system("git clone --bare #{Shellwords.shellescape(path_to_bundle(wiki))} #{Shellwords.shellescape(path_to_repo(wiki))} > /dev/null 2>&1") | 66 | + if system("git clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)} > /dev/null 2>&1") |
68 | puts " [DONE]".green | 67 | puts " [DONE]".green |
69 | else | 68 | else |
70 | puts " [FAILED]".red | 69 | puts " [FAILED]".red |
spec/models/gollum_wiki_spec.rb
1 | require "spec_helper" | 1 | require "spec_helper" |
2 | -require "shellwords" | ||
3 | 2 | ||
4 | describe GollumWiki do | 3 | describe GollumWiki do |
5 | 4 | ||
6 | def create_temp_repo(path) | 5 | def create_temp_repo(path) |
7 | FileUtils.mkdir_p path | 6 | FileUtils.mkdir_p path |
8 | - system("git init --quiet #{Shellwords.shellescape(path)}") | 7 | + command = "git init --quiet #{path};" |
8 | + system(command) | ||
9 | end | 9 | end |
10 | 10 | ||
11 | def remove_temp_repo(path) | 11 | def remove_temp_repo(path) |
spec/models/wiki_page_spec.rb
1 | require "spec_helper" | 1 | require "spec_helper" |
2 | -require "shellwords" | ||
3 | 2 | ||
4 | describe WikiPage do | 3 | describe WikiPage do |
5 | 4 | ||
6 | def create_temp_repo(path) | 5 | def create_temp_repo(path) |
7 | FileUtils.mkdir_p path | 6 | FileUtils.mkdir_p path |
8 | - system("git init --quiet #{Shellwords.shellescape(path)}") | 7 | + command = "git init --quiet #{path};" |
8 | + system(command) | ||
9 | end | 9 | end |
10 | 10 | ||
11 | def remove_temp_repo(path) | 11 | def remove_temp_repo(path) |
spec/support/test_env.rb
1 | require 'rspec/mocks' | 1 | require 'rspec/mocks' |
2 | -require 'shellwords' | ||
3 | 2 | ||
4 | module TestEnv | 3 | module TestEnv |
5 | extend self | 4 | extend self |
@@ -103,7 +102,7 @@ module TestEnv | @@ -103,7 +102,7 @@ module TestEnv | ||
103 | repo = repo(namespace, name) | 102 | repo = repo(namespace, name) |
104 | 103 | ||
105 | # Symlink tmp/repositories/gitlabhq to tmp/test-git-base-path/gitlabhq | 104 | # Symlink tmp/repositories/gitlabhq to tmp/test-git-base-path/gitlabhq |
106 | - system("ln -s -f #{Shellwords.shellescape(seed_repo_path())} #{Shellwords.shellescape(repo)}") | 105 | + system("ln -s -f #{seed_repo_path()} #{repo}") |
107 | create_satellite(repo, namespace, name) | 106 | create_satellite(repo, namespace, name) |
108 | end | 107 | end |
109 | 108 | ||
@@ -167,11 +166,12 @@ module TestEnv | @@ -167,11 +166,12 @@ module TestEnv | ||
167 | # Symlink tmp/satellite/gitlabhq to tmp/test-git-base-path/satellite/gitlabhq, create the directory if it doesn't exist already | 166 | # Symlink tmp/satellite/gitlabhq to tmp/test-git-base-path/satellite/gitlabhq, create the directory if it doesn't exist already |
168 | satellite_dir = File.dirname(satellite_repo) | 167 | satellite_dir = File.dirname(satellite_repo) |
169 | FileUtils.mkdir_p(satellite_dir) unless File.exists?(satellite_dir) | 168 | FileUtils.mkdir_p(satellite_dir) unless File.exists?(satellite_dir) |
170 | - system("ln -s -f #{Shellwords.shellescape(seed_satellite_path)} #{Shellwords.shellescape(satellite_repo)}") | 169 | + system("ln -s -f #{seed_satellite_path} #{satellite_repo}") |
171 | end | 170 | end |
172 | 171 | ||
173 | def create_temp_repo(path) | 172 | def create_temp_repo(path) |
174 | FileUtils.mkdir_p path | 173 | FileUtils.mkdir_p path |
175 | - system("git init --quiet --bare #{Shellwords.shellescape(path)}") | 174 | + command = "git init --quiet --bare #{path};" |
175 | + system(command) | ||
176 | end | 176 | end |
177 | end | 177 | end |