File tree Expand file tree Collapse file tree 2 files changed +11
-21
lines changed
Expand file tree Collapse file tree 2 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,7 @@ class MailTo < Generic
5252 HEADER_REGEXP = /\A (?<hfield>(?:%\h \h |[!$'-.0-;@-Z_a-z~])*=(?:%\h \h |[!$'-.0-;@-Z_a-z~])*)(?:&\g <hfield>)*\z /
5353 # practical regexp for email address
5454 # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
55- EMAIL_REGEXP = %r[\A #{
56- atext = %q[(?:[a-zA-Z0-9!\#$%&'*+\/=?^_`{|}~-]+)]
57- } (?:\. #{ atext } )*@#{
58- label = %q[(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)]
59- } (?:\. #{ label } )*\z ]
55+ EMAIL_REGEXP = /\A [a-zA-Z0-9.!\# $%&'*+\/ =?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\. [a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z /
6056 # :startdoc:
6157
6258 #
Original file line number Diff line number Diff line change @@ -145,29 +145,23 @@ def test_check_to
145145 u . to = 'a@valid.com'
146146 assert_equal ( u . to , 'a@valid.com' )
147147
148- # Invalid emails
149- assert_raise ( URI ::InvalidComponentError ) do
150- u . to = '#1@mail.com'
151- end
148+ # Intentionally allowed violations of RFC 5322
149+ u . to = 'a..a@valid.com'
150+ assert_equal ( u . to , 'a..a@valid.com' )
152151
153- assert_raise ( URI ::InvalidComponentError ) do
154- u . to = '@invalid.email'
155- end
152+ u . to = 'hello.@valid.com'
153+ assert_equal ( u . to , 'hello.@valid.com' )
156154
157- assert_raise ( URI ::InvalidComponentError ) do
158- u . to = '.hello@invalid.email'
159- end
160-
161- assert_raise ( URI ::InvalidComponentError ) do
162- u . to = 'hello.@invalid.email'
163- end
155+ u . to = '.hello@valid.com'
156+ assert_equal ( u . to , '.hello@valid.com' )
164157
158+ # Invalid emails
165159 assert_raise ( URI ::InvalidComponentError ) do
166- u . to = 'n.@invalid.email '
160+ u . to = '#1@mail.com '
167161 end
168162
169163 assert_raise ( URI ::InvalidComponentError ) do
170- u . to = 'n..t @invalid.email'
164+ u . to = '@invalid.email'
171165 end
172166
173167 # Invalid host emails
You can’t perform that action at this time.
0 commit comments