From 4cb30d9f8b091c9eb1d7bf90c2974b96ea3a59f8 Mon Sep 17 00:00:00 2001 From: Hincu Petru Date: Thu, 19 Dec 2013 17:30:01 +0000 Subject: Fixed configurable.rb regular expression name check --- activesupport/lib/active_support/configurable.rb | 2 +- activesupport/test/configurable_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index e0d39d509f..bafcadff9a 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -107,7 +107,7 @@ module ActiveSupport 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__ diff --git a/activesupport/test/configurable_test.rb b/activesupport/test/configurable_test.rb index d00273a028..cb11a4a867 100644 --- a/activesupport/test/configurable_test.rb +++ b/activesupport/test/configurable_test.rb @@ -95,6 +95,12 @@ 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" + end + end end def assert_method_defined(object, method) -- cgit v1.2.3