summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-03-21 14:31:18 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-03-21 15:39:25 -0700
commit072becf6b51cb359d18b30d7eb01391f641dd840 (patch)
tree96a76e3df09413b2e7b7a442460aa71007c3946b /lib
parent9f379b641c05d7e25b4ae92ee449ca66512eff90 (diff)
downloadpuppet-072becf6b51cb359d18b30d7eb01391f641dd840.tar.gz
puppet-072becf6b51cb359d18b30d7eb01391f641dd840.tar.xz
puppet-072becf6b51cb359d18b30d7eb01391f641dd840.zip
(#6806) Improve error checking and reporting for interface naming.
We didn't do enough input checking and sanitization, and missed some edge-cases for naming interfaces. This adds testing, and cleans up some edge cases to handle things better. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/interface.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index dfd75ef58..d169067ea 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -55,12 +55,12 @@ class Puppet::Interface
remove_const(constantize(name)) rescue nil
end
- def self.unify_name(name)
- name.to_s.downcase.to_sym
- end
-
def self.constantize(name)
- name.to_s.split(/\W|_/).map { |x| x.capitalize }.join
+ unless name.to_s =~ /^[-_a-z]+$/i then
+ raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid interface name"
+ end
+
+ name.to_s.split(/[-_]/).map { |x| x.capitalize }.join
end
attr_accessor :default_format