Skip to content
Myr

Merge commit from fork

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Taku Amano · committed by GitHub · parent f4123ed · Browse files · 2 files+30 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+30 added−0 removed

  • tests:+24 added−0 removed
  • other:+6 added−0 removed

2 files+30 added−0 removed

modified:src/utils/cookie.test.ts+24 added
268 unmodified lines
269 })270 }).toThrowError('Partitioned Cookie must have Secure attributes')271 })272273 it('Should throw Error cookie with domain or path containing ";", "\\r", or "\\n"', () => {274 // domain275 expect(() => {276 serialize('great_cookie', 'banana', { domain: 'example.com;evil' })277 }).toThrowError('domain must not contain ";", "\\r", or "\\n"')278 expect(() => {279 serialize('great_cookie', 'banana', { domain: 'example.com\revil' })280 }).toThrowError('domain must not contain ";", "\\r", or "\\n"')281 expect(() => {282 serialize('great_cookie', 'banana', { domain: 'example.com\nevil' })283 }).toThrowError('domain must not contain ";", "\\r", or "\\n"')284285 // path286 expect(() => {287 serialize('great_cookie', 'banana', { path: '/;evil' })288 }).toThrowError('path must not contain ";", "\\r", or "\\n"')289 expect(() => {290 serialize('great_cookie', 'banana', { path: '/\revil' })291 }).toThrowError('path must not contain ";", "\\r", or "\\n"')292 expect(() => {293 serialize('great_cookie', 'banana', { path: '/\nevil' })294 }).toThrowError('path must not contain ";", "\\r", or "\\n"')295 })296297 it('Should serialize cookie with lowercase priority values', () => {298 const lowSerialized = serialize('test_cookie', 'value', {299 priority: 'low',300 })
13 unmodified lines
modified:src/utils/cookie.ts+6 added
159 unmodified lines
160 throw new Error('__Host- Cookie must not have Domain attributes')161 }162 }163164 for (const key of ['domain', 'path'] as (keyof CookieOptions)[]) {165 if (opt[key] && /[;\r\n]/.test(opt[key] as string)) {166 throw new Error(`${key} must not contain ";", "\\r", or "\\n"`)167 }168 }169170 if (opt && typeof opt.maxAge === 'number' && opt.maxAge >= 0) {171 if (opt.maxAge > 34560000) {172 // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-5.6.2173 throw new Error(
71 unmodified lines