File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ class Cookie < Array
42
42
43
43
TOKEN_RE = %r"\A [[!-~]&&[^()<>@,;:\\ \" /?=\[ \] {}]]+\z "
44
44
PATH_VALUE_RE = %r"\A [[ -~]&&[^;]]*\z "
45
- DOMAIN_VALUE_RE = %r"\A (?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\. \g <label>)*\z "
45
+ DOMAIN_VALUE_RE = %r"\A \. ? (?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\. \g <label>)*\z "
46
46
47
47
# Create a new CGI::Cookie object.
48
48
#
Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ def test_cgi_cookie_new_with_domain
65
65
cookie = CGI ::Cookie . new ( h . merge ( 'domain' => 'a.example.com' ) )
66
66
assert_equal ( 'a.example.com' , cookie . domain )
67
67
68
+ cookie = CGI ::Cookie . new ( h . merge ( 'domain' => '.example.com' ) )
69
+ assert_equal ( '.example.com' , cookie . domain )
70
+
68
71
cookie = CGI ::Cookie . new ( h . merge ( 'domain' => '1.example.com' ) )
69
72
assert_equal ( '1.example.com' , cookie . domain , 'enhanced by RFC 1123' )
70
73
You can’t perform that action at this time.
0 commit comments