summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_cookie.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-22 11:05:52 +0900
committergit <svn-admin@ruby-lang.org>2022-11-22 02:12:50 +0000
commit58682b6980e9c2046f4b18025c4b684661fbcf66 (patch)
tree812df44c0bb141b752a6876139ea9db0983d5b3e /test/cgi/test_cgi_cookie.rb
parent5304b3bd85b55944bff89aee0bd08dddf64f8805 (diff)
[ruby/cgi] Relax domain label restrictions
https://github.com/ruby/cgi/commit/b46d41c363
Diffstat (limited to 'test/cgi/test_cgi_cookie.rb')
-rw-r--r--test/cgi/test_cgi_cookie.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_cookie.rb b/test/cgi/test_cgi_cookie.rb
index 2f09d0f9b2..e3ec4bea52 100644
--- a/test/cgi/test_cgi_cookie.rb
+++ b/test/cgi/test_cgi_cookie.rb
@@ -60,6 +60,24 @@ class CGICookieTest < Test::Unit::TestCase
end
+ def test_cgi_cookie_new_with_domain
+ h = {'name'=>'name1', 'value'=>'value1'}
+ cookie = CGI::Cookie.new('domain'=>'a.example.com', **h)
+ assert_equal('a.example.com', cookie.domain)
+
+ cookie = CGI::Cookie.new('domain'=>'1.example.com', **h)
+ assert_equal('1.example.com', cookie.domain, 'enhanced by RFC 1123')
+
+ assert_raise(ArgumentError) {
+ CGI::Cookie.new('domain'=>'-a.example.com', **h)
+ }
+
+ assert_raise(ArgumentError) {
+ CGI::Cookie.new('domain'=>'a-.example.com', **h)
+ }
+ end
+
+
def test_cgi_cookie_scriptname
cookie = CGI::Cookie.new('name1', 'value1')
assert_equal('', cookie.path)