rails/actionpack/test/dispatch
Gareth Adams 8f3c6a1005 Make Rails cookies RFC6265-compliant with domain: :all
Rails has incorrectly been adding leading dots to cookie domain values
when the `domain: :all` option is present.

This leading dot was required in cookies based on [RFC 2965][rfc2965]
(October 2000), but [RFC 6265][rfc6265] (April 2011) changed that
behaviour, making a leading dot strictly incorrect. Todays browsers aim
to confirm to RFC6265 with repect to cookies.

The new behaviour is that *any* cookie with an explicitly passed domain
is sent to all matching subdomains[[ref][mdn]]. For a server to indicate
that only the exact origin server should receive the cookie, it should
instead pass *no* domain attribute.

Despite the change in behaviour, browser devtools often display a cookie
domain with a leading dot to indicate that it is valid for subdomains -
this prefixed domain is *not* necessarily the raw value that was passed
in the Set-Cookie header. This explains why it's a common belief among
developers that the leading dot is required.

RFC6265 standard gives UAs an algorithm to handle old-style cookie
domain parameters (they can drop a leading dot if present), so it's
unlikely that this error would ever have had any effect on web browsers.

However, cookies generated this way can't be processed by Ruby's own
CGI::Cookie class:

> CGI::Cookie.new "domain" => ".foo.bar", "name" => "foo"
ArgumentError: invalid domain: ".foo.bar"

Newer versions of the Ruby CGI library accomodate the same fallback
behaviour (dropping the extra dot) but this isn't a justification for it
being the right way to set a cookie.

[mdn]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#domain_attribute
[rfc2965]: https://www.rfc-editor.org/rfc/rfc2965#section-3.2
[rfc6265]: https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1
2023-04-24 01:38:34 +01:00
..
request Add ActionDispatch.deprecator 2022-10-27 17:11:02 -05:00
routing Print source location when inspecting routes 2023-04-10 09:52:27 -04:00
session Make Rails cookies RFC6265-compliant with domain: :all 2023-04-24 01:38:34 +01:00
system_testing Remove deprecated poltergeist and webkit (capybara-webkit) driver registration for system testing 2023-03-03 00:38:23 +00:00
actionable_exceptions_test.rb Only allow ActionableErrors if show_detailed_exceptions is enabled 2020-06-17 07:59:57 -07:00
callbacks_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
content_disposition_test.rb Escape # in RFC 5987 pattern 2020-08-31 10:31:30 -04:00
content_security_policy_test.rb Do not return CSP headers for 304 Not Modified responses 2022-08-19 15:10:47 +02:00
cookies_test.rb Make Rails cookies RFC6265-compliant with domain: :all 2023-04-24 01:38:34 +01:00
debug_exceptions_test.rb Fix word case. html -> HTML 2022-09-18 04:21:22 +10:00
debug_locks_test.rb Fix can't modify frozen String error in DebugLocks 2017-08-28 21:48:05 +09:00
exception_wrapper_test.rb Only deal with backtrace locations in ExceptionWrapper 2022-10-09 14:52:17 -07:00
executor_test.rb Fix style and misspell in action dispatch executor test 2022-02-11 14:55:33 -05:00
header_test.rb Remove Rubocop's comments from Rails code base 2018-07-26 23:37:31 +03:00
host_authorization_test.rb Allow IPs with port in the HostAuthorization middleware 2021-12-15 21:41:50 +00:00
live_response_test.rb Normalize usage of "Headers". 2023-01-26 12:06:24 +13:00
mapper_test.rb Anchor the Action Cable server's route 2022-06-29 13:26:49 -05:00
middleware_stack_test.rb Add back Rack::Runtime to the default middleware stack. 2021-09-15 18:37:34 -04:00
mime_type_test.rb Prevent catastrophic backtracking during mime parsing 2021-05-04 13:49:41 -07:00
mount_test.rb mounted routes with non-word characters 2019-04-15 15:11:13 +02:00
permissions_policy_test.rb Add ActionDispatch.deprecator 2022-10-27 17:11:02 -05:00
prefix_generation_test.rb Remove body content from redirect responses 2022-02-25 13:31:54 -04:00
rack_cache_test.rb Use frozen string literal in actionpack/ 2017-07-29 14:02:40 +03:00
reloader_test.rb Replace assert ! with assert_not 2018-04-19 08:11:33 -04:00
request_id_test.rb Fix tests with Ruby 3 2020-10-30 02:20:04 +00:00
request_test.rb Remove deprecated behavior on Request#content_type 2023-03-03 00:38:21 +00:00
response_test.rb Merge pull request #47092 from ioquatix/rack-3-streaming-body 2023-02-14 17:01:45 -08:00
routing_assertions_test.rb chore: fix spelling 2021-04-15 15:49:48 +10:00
routing_test.rb Add ActionDispatch.deprecator 2022-10-27 17:11:02 -05:00
runner_test.rb Use frozen string literal in actionpack/ 2017-07-29 14:02:40 +03:00
server_timing_test.rb Fix ServerTiming in Threads, use single subscriber 2022-09-08 21:05:33 -07:00
show_exceptions_test.rb Raise more specific exception for invalid mime type from user-agent 2020-10-07 11:49:56 -04:00
ssl_test.rb Fix #47535 - flag multiple cookies as secure 2023-03-08 12:29:26 -05:00
static_test.rb Expect Static to set lowercase values in Vary 2023-02-26 19:36:29 +10:30
test_request_test.rb Don't assume these fields will be present in a rack env. 2023-01-21 05:53:20 +13:00
test_response_test.rb ActionDispatch::Testing::TestResponse#parsed_body parse HTML with Nokogiri 2023-01-27 23:52:21 -05:00
uploaded_file_test.rb Encodes the uploaded file's headers - Closes #38080 2021-02-22 17:01:39 -03:00
url_generation_test.rb Fix setting trailing_slash: true in route definition 2022-02-15 10:44:33 +01:00