Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow special use domains by default #249

Merged
merged 1 commit into from Aug 24, 2022

Conversation

colincasey
Copy link
Contributor

To avoid breaking behavior the allowSpecialUseDomain option should have been set to true by default.

This PR also adds tests that cover when a default CookieStore is created it does allow cookies with special use domains.

closes #246

To avoid breaking behavior the `allowSpecialUseDomain` option should have been set to `true` by default.

This PR also adds tests that cover when a default `CookieStore` is created it does allow cookies with special use domains.

closes #246
@colincasey colincasey added the patch We expect this work to be a patch level change label Aug 24, 2022
@colincasey colincasey self-assigned this Aug 24, 2022
Copy link

@halivert halivert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @colincasey, great work 🎉

lib/cookie.js Show resolved Hide resolved
@awaterma
Copy link
Member

Looks good to me as well @colincasey; nice to see a fix that makes a change and adds a test. :)

I've also hand-checked straight localhost creation:

cookie@d8759915569c:~$ node 
Welcome to Node.js v16.17.0.
Type ".help" for more information.
> const Cookie = require(".")
undefined
> jar = new Cookie.CookieJar();
CookieJar {
  rejectPublicSuffixes: true,
  enableLooseMode: false,
  allowSpecialUseDomain: true,
  store: { idx: {} },
  prefixSecurity: 'silent',
  _cloneSync: [Function (anonymous)],
  _importCookiesSync: [Function (anonymous)],
  getCookiesSync: [Function (anonymous)],
  getCookieStringSync: [Function (anonymous)],
  getSetCookieStringsSync: [Function (anonymous)],
  removeAllCookiesSync: [Function (anonymous)],
  setCookieSync: [Function (anonymous)],
  serializeSync: [Function (anonymous)]
}
> await(jar.setCookie('settingThisShouldPass=true,Domain=localhost; Path="/;"','http://localhost'))
Cookie="settingThisShouldPass=true,Domain=localhost; Path=/; "; hostOnly=true; aAge=1ms; cAge=1ms"

Copy link
Member

@awaterma awaterma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@awaterma
Copy link
Member

Merging with single approval and discussion with @colincasey. Will work on our 4.1.1 release next.

@awaterma awaterma merged commit d4ac580 into master Aug 24, 2022
@awaterma awaterma deleted the fix/246_allow_special_use_domains_by_default branch August 24, 2022 18:16
@CSchulz
Copy link

CSchulz commented Aug 24, 2022

This doesn't close #246 completly, because there is still the breaking change mentioned in #248 contained.
If you are using localhost as test environment url it is not enough, you have to change it to something else like localhost.local.

@Sourav-techlur
Copy link

Hey @awaterma I am still having the same issue with v4.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch We expect this work to be a patch level change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.1 introduced breaking changes
6 participants