Skip to content

Commit

Permalink
Use valid tokens as cookie names
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Nov 22, 2022
1 parent 32d202e commit 36f297e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions spec/ruby/library/cgi/cookie/name_spec.rb
Expand Up @@ -6,18 +6,18 @@
cookie = CGI::Cookie.new("test-cookie")
cookie.name.should == "test-cookie"

cookie = CGI::Cookie.new("name" => "another cookie")
cookie.name.should == "another cookie"
cookie = CGI::Cookie.new("name" => "another-cookie")
cookie.name.should == "another-cookie"
end
end

describe "CGI::Cookie#name=" do
it "sets self's expiration date" do
cookie = CGI::Cookie.new("test-cookie")
cookie.name = "another name"
cookie.name.should == "another name"
cookie.name = "another-name"
cookie.name.should == "another-name"

cookie.name = "and one more"
cookie.name.should == "and one more"
cookie.name = "and-one-more"
cookie.name.should == "and-one-more"
end
end
10 changes: 5 additions & 5 deletions spec/ruby/library/cgi/cookie/parse_spec.rb
Expand Up @@ -6,16 +6,16 @@
expected = { "test-cookie" => ["one", "two", "three"] }
CGI::Cookie.parse("test-cookie=one&two&three").should == expected

expected = { "second cookie" => ["three", "four"], "first cookie" => ["one", "two"] }
CGI::Cookie.parse("first cookie=one&two;second cookie=three&four").should == expected
expected = { "second-cookie" => ["three", "four"], "first-cookie" => ["one", "two"] }
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four").should == expected
end

it "does not use , for cookie separators" do
expected = {
"first cookie" => ["one", "two"],
"second cookie" => ["three", "four,third_cookie=five", "six"]
"first-cookie" => ["one", "two"],
"second-cookie" => ["three", "four,third_cookie=five", "six"]
}
CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four,third_cookie=five&six").should == expected
end

it "unescapes the Cookie values" do
Expand Down

0 comments on commit 36f297e

Please sign in to comment.