Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosen the domain regex to accept '.' #29

Merged
merged 5 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cgi/cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Cookie < Array

TOKEN_RE = %r"\A[[!-~]&&[^()<>@,;:\\\"/?=\[\]{}]]+\z"
PATH_VALUE_RE = %r"\A[[ -~]&&[^;]]*\z"
DOMAIN_VALUE_RE = %r"\A(?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\.\g<label>)*\z"
DOMAIN_VALUE_RE = %r"\A(?<label>(?!-)\.?[-A-Za-z0-9]+(?<!-))(?:\.\g<label>)*\z"
tubaxenor marked this conversation as resolved.
Show resolved Hide resolved

# Create a new CGI::Cookie object.
#
Expand Down
3 changes: 3 additions & 0 deletions test/cgi/test_cgi_cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def test_cgi_cookie_new_with_domain
cookie = CGI::Cookie.new('domain'=>'a.example.com', **h)
assert_equal('a.example.com', cookie.domain)

cookie = CGI::Cookie.new('domain'=>'.example.com', **h)
assert_equal('.example.com', cookie.domain)

cookie = CGI::Cookie.new('domain'=>'1.example.com', **h)
assert_equal('1.example.com', cookie.domain, 'enhanced by RFC 1123')

Expand Down