Permalink
Browse files

let this regexp be stricter

The purpose of this regexp is to detect strings that
are valid identifiers to be used as method names.
The anchor $ allows a trailing newline, and both ^
and $ may be bypassed because Ruby regexps are
multiline always. The anchors \A and \z are the
proper ones to ensure string boundaries.
  • Loading branch information...
1 parent a3a5c7e commit 9b423ac0b73483c4a812d7376f818e831f909120 @fxn fxn committed Apr 19, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/attribute_methods.rb
@@ -56,7 +56,7 @@ class MissingAttributeError < NoMethodError
module AttributeMethods
extend ActiveSupport::Concern
- COMPILABLE_REGEXP = /^[a-zA-Z_]\w*[!?=]?$/
+ COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?=]?\z/
included do
class_attribute :attribute_method_matchers, :instance_writer => false

0 comments on commit 9b423ac

Please sign in to comment.