1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make sure multiline string is not accepted by the regexp

This commit is contained in:
Rafael Mendonça França 2013-12-19 17:27:52 -02:00
parent bfdae1775a
commit 04ad814bb9
2 changed files with 10 additions and 2 deletions

View file

@ -107,7 +107,7 @@ module ActiveSupport
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__

View file

@ -95,10 +95,18 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase
config_accessor "invalid attribute name"
end
end
assert_raises NameError do
Class.new do
include ActiveSupport::Configurable
config_accessor "invalid attribute\nname"
config_accessor "invalid\nattribute"
end
end
assert_raises NameError do
Class.new do
include ActiveSupport::Configurable
config_accessor "invalid\n"
end
end
end