summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-10-27 11:43:48 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2019-12-02 22:06:02 +0530
commit87fc4d22f869bde6f3fe3756718b6d12713c2bab (patch)
treee6144abf56579ca001ff528f3c22557d8d3ea08d
parent9009b12f14272522c08b2d19c94ae3e418867f56 (diff)
downloadchef-87fc4d22f869bde6f3fe3756718b6d12713c2bab.tar.gz
Fix apt_repository uri single/double quotes and spaces
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/provider/apt_repository.rb6
-rw-r--r--spec/unit/provider/apt_repository_spec.rb10
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index 85fac1d2da..106e1e65c1 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -321,8 +321,6 @@ class Chef
# @return [String] complete repo config text
def build_repo(uri, distribution, components, trusted, arch, add_src = false)
uri = make_ppa_url(uri) if is_ppa_url?(uri)
-
- uri = '"' + uri + '"' unless uri.start_with?("'", '"')
components = Array(components).join(" ")
options = []
options << "arch=#{arch}" if arch
@@ -331,8 +329,8 @@ class Chef
"[" + options.join(" ") + "]"
end
info = [ optstr, uri, distribution, components ].compact.join(" ")
- repo = "deb #{info}\n"
- repo << "deb-src #{info}\n" if add_src
+ repo = "deb #{info}\n"
+ repo << "deb-src #{info}\n" if add_src
repo
end
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index 11d505dad8..df39abcd4e 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -226,27 +226,27 @@ C5986B4F1257FFA86632CBA746181433FBB75451
describe "#build_repo" do
it "creates a repository string" do
- target = %Q{deb "http://test/uri" unstable main\n}
+ target = "deb http://test/uri unstable main\n"
expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil)).to eql(target)
end
it "creates a repository string with no distribution" do
- target = %Q{deb "http://test/uri" main\n}
+ target = "deb http://test/uri main\n"
expect(provider.build_repo("http://test/uri", nil, "main", false, nil)).to eql(target)
end
it "creates a repository string with source" do
- target = %Q{deb "http://test/uri" unstable main\ndeb-src "http://test/uri" unstable main\n}
+ target = "deb http://test/uri unstable main\ndeb-src http://test/uri unstable main\n"
expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, true)).to eql(target)
end
it "creates a repository string with options" do
- target = %Q{deb [trusted=yes] "http://test/uri" unstable main\n}
+ target = "deb [trusted=yes] http://test/uri unstable main\n"
expect(provider.build_repo("http://test/uri", "unstable", "main", true, nil)).to eql(target)
end
it "handles a ppa repo" do
- target = %Q{deb "http://ppa.launchpad.net/chef/main/ubuntu" unstable main\n}
+ target = "deb http://ppa.launchpad.net/chef/main/ubuntu unstable main\n"
expect(provider).to receive(:make_ppa_url).with("ppa:chef/main").and_return("http://ppa.launchpad.net/chef/main/ubuntu")
expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil)).to eql(target)
end