Skip to content

Commit 0685e8c

Browse files
nlevchukmatzbot
authored andcommitted
[ruby/uri] lib/uri/mailto.rb (EMAIL_REGEXP): the local part should not contain leading or trailing dots
ruby/uri@618e2bb640
1 parent f176462 commit 0685e8c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-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[^.][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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def test_check_to
148148
assert_raise(URI::InvalidComponentError) do
149149
u.to = '@invalid.email'
150150
end
151+
152+
assert_raise(URI::InvalidComponentError) do
153+
154+
end
155+
156+
assert_raise(URI::InvalidComponentError) do
157+
158+
end
151159
end
152160

153161
def test_to_s

0 commit comments

Comments
 (0)