Permalink
Browse files

Make sure multiline string is not accepted by the regexp

  • Loading branch information...
1 parent bfdae17 commit 04ad814bb992e854927c1bec3422df882f017ab6 @rafaelfranca rafaelfranca committed Dec 19, 2013
Showing with 10 additions and 2 deletions.
  1. +1 −1 activesupport/lib/active_support/configurable.rb
  2. +9 −1 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[_A-Za-z]\w*\Z/
+ raise NameError.new('invalid config attribute name') unless name =~ /\A[_A-Za-z]\w*\z/
reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
@@ -95,10 +95,18 @@ class Child < Parent
config_accessor "invalid attribute name"
end
end
+
+ assert_raises NameError do
+ Class.new do
+ include ActiveSupport::Configurable
+ config_accessor "invalid\nattribute"
+ end
+ end
+
assert_raises NameError do
Class.new do
include ActiveSupport::Configurable
- config_accessor "invalid attribute\nname"
+ config_accessor "invalid\n"
end
end
end

1 comment on commit 04ad814

❤️

Please sign in to comment.