diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-21 17:06:34 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-21 17:06:34 +0000 |
| commit | ea4b9c83810976235d3486d42e22ec8cf279abf1 (patch) | |
| tree | 47d96c63d4df72bedba65debce315f7601290734 | |
| parent | c99843a75a837c042d231242896851ff56e91d34 (diff) | |
| download | puppet-ea4b9c83810976235d3486d42e22ec8cf279abf1.tar.gz puppet-ea4b9c83810976235d3486d42e22ec8cf279abf1.tar.xz puppet-ea4b9c83810976235d3486d42e22ec8cf279abf1.zip | |
Fixing #285, opened by ericb.
The problem here was that I was not escaping URIs throughout the chain, which
I am now doing.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1642 980ebf18-57e1-0310-9a29-db15c13687c0
| -rwxr-xr-x | lib/puppet/server/fileserver.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/type/pfile.rb | 14 | ||||
| -rwxr-xr-x | test/types/filesources.rb | 33 |
3 files changed, 40 insertions, 9 deletions
diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb index cb32212c9..85f0f5016 100755 --- a/lib/puppet/server/fileserver.rb +++ b/lib/puppet/server/fileserver.rb @@ -198,6 +198,8 @@ class Server def convert(url, client, clientip) readconfig + url = URI.unescape(url) + mount, stub = splitpath(url, client) authcheck(url, mount, client, clientip) diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 86b608c07..7ce384077 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -740,25 +740,21 @@ module Puppet end end - #ignore = self[:ignore] || false ignore = self[:ignore] - #self.warning "Listing path %s with ignore %s" % - # [path.inspect, ignore.inspect] desc = server.list(path, self[:links], r, ignore) - + + # Now create a new child for every file returned in the list. desc.split("\n").each { |line| file, type = line.split("\t") - next if file == "/" + next if file == "/" # skip the listing object name = file.sub(/^\//, '') - #self.warning "child name is %s" % name args = {:source => source + file} if type == file args[:recurse] = nil end + self.newchild(name, false, args) - #self.newchild(hash, source, recurse) - #hash2child(hash, source, recurse) } end @@ -862,7 +858,7 @@ module Puppet sourceobj.local = true end begin - uri = URI.parse(source) + uri = URI.parse(URI.escape(source)) rescue => detail self.fail "Could not understand source %s: %s" % [source, detail.to_s] diff --git a/test/types/filesources.rb b/test/types/filesources.rb index 3cc546b40..f121586c3 100755 --- a/test/types/filesources.rb +++ b/test/types/filesources.rb @@ -639,6 +639,39 @@ class TestFileSources < Test::Unit::TestCase # Make sure it doesn't change. assert_equal("funtest\n", File.read(dest)) end + + # Testing #285. This just makes sure that URI parsing works correctly. + def test_fileswithpoundsigns + dir = tstdir() + subdir = File.join(dir, "#dir") + Dir.mkdir(subdir) + file = File.join(subdir, "file") + File.open(file, "w") { |f| f.puts "yayness" } + + dest = tempfile() + source = "file://localhost#{dir}" + obj = Puppet::Type.newfile( + :path => dest, + :source => source, + :recurse => true + ) + + newfile = File.join(dest, "#dir", "file") + + poundsource = "file://localhost#{subdir}" + + sourceobj = path = nil + assert_nothing_raised { + sourceobj, path = obj.uri2obj(poundsource) + } + + assert_equal("/localhost" + URI.escape(subdir), path) + + assert_apply(obj) + + assert(FileTest.exists?(newfile), "File did not get created") + assert_equal("yayness\n", File.read(newfile)) + end end # $Id$ |
