Ruby:The provided regular expression is using multiline anchors (^ or $), which may present a securi

Ruby 从3.0到4.0

validates 正则表达式

check_options_validity': The provided regular expression is using multiline anchors (^ or $)
rails4中validates不支持 ^ 和 $ , 替换成\A 和 \z

  -  ACCOUNT_EMAIL_FORMAT = /^\s*#{FORMAT}\s*$/
  +  ACCOUNT_EMAIL_FORMAT = /\A\s*#{FORMAT}\s\z/

方式一,使用\A \z替代 ^ $
validates :mobile_number, :format => { :with => FORMAT }, :allow_blank => true
方式二,使用multiline: true说明
validates :content, format: { with: /^Meanwhile$/, multiline: true }

http://stackoverflow.com/questions/17759735/regular-expressions-with-validations-in-ror-4
http://guides.rubyonrails.org/security.html#regular-expressions


你可能感兴趣的:(Ruby:The provided regular expression is using multiline anchors (^ or $), which may present a securi)