summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 00:28:16 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 00:28:16 +0000
commitf792a02aa153eedf5293791daaf355232f357cc4 (patch)
tree9f8016c956afdcd4391999c87c79641e8306efe0 /lib/puppet/parser/functions.rb
parent8b60619f5857569c2971237c80cf214cb8e71b3f (diff)
downloadpuppet-f792a02aa153eedf5293791daaf355232f357cc4.tar.gz
puppet-f792a02aa153eedf5293791daaf355232f357cc4.tar.xz
puppet-f792a02aa153eedf5293791daaf355232f357cc4.zip
Moving the template handling into a simple wrapper object so templates don't have full access to the scope object without some real hacking.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1342 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/functions.rb')
-rw-r--r--lib/puppet/parser/functions.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index cec7c02c5..38ba0da9f 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -125,22 +125,16 @@ module Functions
require 'erb'
vals.collect do |file|
- unless file =~ /^#{File::SEPARATOR}/
- file = File.join(Puppet[:templatedir], file)
- end
-
- unless File.exists?(file)
- raise Puppet::ParseError,
- "Could not find template %s" % file
- end
-
- template = ERB.new(File.read(file))
+ # Use a wrapper, so the template can't get access to the full
+ # Scope object.
+ wrapper = Puppet::Parser::Scope::TemplateWrapper.new(self, file)
begin
- template.result(binding)
+ wrapper.result()
rescue => detail
- raise Puppet::ParseError, "Could not interpret template %s: %s" %
- [file, detail]
+ raise Puppet::ParseError,
+ "Failed to parse template %s: %s" %
+ [file, detail]
end
end.join("")
end