mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 10:03:59 +02:00
[ruby/cgi] Loosen the domain regex to accept '.'
(https://github.com/ruby/cgi/pull/29)
* Loosen the domain regex to accept '.'
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
5e09d632f3
Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
This commit is contained in:
parent
1612d57691
commit
745dcf5326
2 changed files with 4 additions and 1 deletions
|
@ -42,7 +42,7 @@ class CGI
|
|||
|
||||
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"
|
||||
|
||||
# Create a new CGI::Cookie object.
|
||||
#
|
||||
|
|
|
@ -65,6 +65,9 @@ class CGICookieTest < Test::Unit::TestCase
|
|||
cookie = CGI::Cookie.new(h.merge('domain'=>'a.example.com'))
|
||||
assert_equal('a.example.com', cookie.domain)
|
||||
|
||||
cookie = CGI::Cookie.new(h.merge('domain'=>'.example.com'))
|
||||
assert_equal('.example.com', cookie.domain)
|
||||
|
||||
cookie = CGI::Cookie.new(h.merge('domain'=>'1.example.com'))
|
||||
assert_equal('1.example.com', cookie.domain, 'enhanced by RFC 1123')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue