diff --git a/lib/data_mapper/validation/rule/formats/email.rb b/lib/data_mapper/validation/rule/formats/email.rb index 34021ff8..0918b12f 100644 --- a/lib/data_mapper/validation/rule/formats/email.rb +++ b/lib/data_mapper/validation/rule/formats/email.rb @@ -27,7 +27,7 @@ module Formats end digit = '0-9' atext = "[#{letter}#{digit}\!\#\$\%\&\'\*+\/\=\?\^\_\`\{\|\}\~\-]" - dot_atom_text = "#{atext}+([.]#{atext}*)+" + dot_atom_text = "#{atext}+([.]#{atext}+)+" dot_atom = dot_atom_text no_ws_ctl = '\x01-\x08\x11\x12\x14-\x1f\x7f' qtext = "[^#{no_ws_ctl}\\x0d\\x22\\x5c]" # Non-whitespace, non-control character except for \ and " diff --git a/spec/integration/format_validator/email_format_validator_spec.rb b/spec/integration/format_validator/email_format_validator_spec.rb index 9db2488f..782bd7f3 100644 --- a/spec/integration/format_validator/email_format_validator_spec.rb +++ b/spec/integration/format_validator/email_format_validator_spec.rb @@ -42,7 +42,12 @@ def valid_attributes 'Job@Book of Job', 'test@localhost', 'J. P. \'s-Gravezande, a.k.a. The Hacker!@example.com', - "test@example.com\nsomething after the newline"].each do |email| + "test@example.com\nsomething after the newline", + 'mal.@example.com', + 'mal.formed.@example.com', + 'mal.formed@example.', + 'mal.formed@example.com.', + 'mal.formed@example...com'].each do |email| describe "with email value of #{email} (non RFC2822 compliant)" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:email => email))