提交 f70e94cb 编写于 作者: R Rafael Mendonça França

Merge pull request #13406 from hincupetru/master

Fixed configurable.rb regular expression name check
......@@ -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/
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册