Permalink
Browse files

Fixed configurable.rb regular expression name check

  • Loading branch information...
1 parent cc1f0b4 commit 4cb30d9f8b091c9eb1d7bf90c2974b96ea3a59f8 @hpetru hpetru committed Dec 19, 2013
Showing with 7 additions and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/configurable.rb
  2. +6 −0 activesupport/test/configurable_test.rb
@@ -107,7 +107,7 @@ def config_accessor(*names)
options = names.extract_options!
names.each do |name|
- raise NameError.new('invalid config attribute name') unless name =~ /^[_A-Za-z]\w*$/
+ raise NameError.new('invalid config attribute name') unless name =~ /\A[_A-Za-z]\w*\Z/
@JuanitoFatas

JuanitoFatas Dec 19, 2013

Contributor

@hincupetru \Z => \z?

@rafaelfranca

rafaelfranca Dec 19, 2013

Owner

👍 I'm doing this already

@JuanitoFatas

JuanitoFatas Dec 19, 2013

Contributor

@rafaelfranca Awesome! Thanks.

reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
@@ -95,6 +95,12 @@ class Child < Parent
config_accessor "invalid attribute name"
end
end
+ assert_raises NameError do
+ Class.new do
+ include ActiveSupport::Configurable
+ config_accessor "invalid attribute\nname"
+ end
+ end
end
def assert_method_defined(object, method)

0 comments on commit 4cb30d9

Please sign in to comment.