Skip to content

apply the public suffix filter in the no-arg RFC6265CookieSpecFactory - #955

Open
Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:cookie-spec-factory-psl
Open

Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:cookie-spec-factory-psl

Conversation

@Hsnmohd

@Hsnmohd Hsnmohd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

The no-arg RFC6265CookieSpecFactory constructor passes a null PublicSuffixMatcher, so the specs it creates skip PublicSuffixDomainFilter and a Domain=com cookie set by foo.com is sent to bar.com; default it to PublicSuffixMatcherLoader.getDefault() as #944 did for the no-arg RFC6265LaxSpec and RFC6265StrictSpec constructors.

@arturobernalg

Copy link
Copy Markdown
Member

This changes the observable behavior of the public no-arg constructor and may affect existing applications relying on the previous default.
RFC 6265 does not require public suffix filtering to be enabled by default. Is there a compelling reason to introduce this behavioral change rather than preserve backward compatibility?

@Hsnmohd

Hsnmohd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Agreed that RFC 6265 leaves public suffix rejection to user agent configuration (5.3 step 5), so this isn't a spec compliance point. The argument is consistency with what the project already treats as its default: the default cookie policy has validated against the PSL since 4.4, CookieSpecSupport.createDefault() wires PublicSuffixMatcherLoader.getDefault() into the same factory, and #944 just made the no-arg RFC6265LaxSpec and RFC6265StrictSpec constructors do it too. The no-arg factory is the one remaining default-looking entry point that silently produces the unfiltered spec, and it has the same practical consequence #944 fixed: a Domain=com cookie set by foo.com gets sent to bar.com.

Anyone who needs the old behavior still has an explicit way to ask for it, new RFC6265CookieSpecFactory(CompatibilityLevel.RELAXED, null), so the change is a default shift rather than a capability loss. I'd keep it for that reason, but if you'd rather preserve the no-arg default as is, I'm fine closing this and we can instead note the opt-out and the asymmetry with #944 in the javadoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants