Skip to content

Commit 1add45e

Browse files
nobumatzbot
authored andcommitted
[ruby/uri] Prohibit successive dots in email
ruby/uri@32335923bf
1 parent 859d742 commit 1add45e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/uri/mailto.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +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 = /\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/
55+
EMAIL_REGEXP = /\A(?!\.)(?!.*\.{2})[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/
5656
# :startdoc:
5757

5858
#

test/uri/test_mailto.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def test_check_to
166166
167167
end
168168

169+
assert_raise(URI::InvalidComponentError) do
170+
171+
end
172+
169173
# Invalid host emails
170174
assert_raise(URI::InvalidComponentError) do
171175

0 commit comments

Comments
 (0)