Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed configurable.rb regular expression name check

  • Loading branch information...
commit 4cb30d9f8b091c9eb1d7bf90c2974b96ea3a59f8 1 parent cc1f0b4
@hpetru hpetru authored
View
2  activesupport/lib/active_support/configurable.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/

@hincupetru \Z => \z?

@rafaelfranca Owner

:+1: I'm doing this already

@rafaelfranca Awesome! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
View
6 activesupport/test/configurable_test.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.