summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/leaf.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index eeeee45fd..609bcd3cc 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -70,7 +70,16 @@ class Puppet::Parser::AST
class Name < AST::Leaf; end
# Host names, either fully qualified or just the short name
- class HostName < AST::Leaf; end
+ class HostName < AST::Leaf
+ def initialize(hash)
+ super
+
+ unless @value =~ %r{^[0-9a-zA-Z\-]+(\.[0-9a-zA-Z\-]+)*$}
+ raise Puppet::DevError,
+ "'%s' is not a valid hostname" % @value
+ end
+ end
+ end
# A simple variable. This object is only used during interpolation;
# the VarDef class is used for assignment.