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 5463db2 · Browse files · 2 files·+24 added−2 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+24 added−2 removed
- tests:+23 added−1 removed
- other:+1 added−1 removed
Provenance
- Commit
905aedb- Tree
87025ea- Author
Taku Amano <taku@taaas.jp>- Committer
GitHub <noreply@github.com>- Parent
5463db2
2 files changed+24 added−2 removed
modified:src/utils/cookie.test.ts+23 added-1 removed
348 unmodified lines349 })350 }).toThrowError('Partitioned Cookie must have Secure attributes')351 })352 353- it('Should throw Error cookie with domain or path containing ";", "\\r", or "\\n"', () => {353+ it('Should throw Error cookie with domain, path, sameSite, or priority containing ";", "\\r", or "\\n"', () => {354 // domain355 expect(() => {356 serialize('great_cookie', 'banana', { domain: 'example.com;evil' })357 }).toThrowError('domain must not contain ";", "\\r", or "\\n"')13 unmodified lines371 }).toThrowError('path must not contain ";", "\\r", or "\\n"')372 expect(() => {373 serialize('great_cookie', 'banana', { path: '/\nevil' })374 }).toThrowError('path must not contain ";", "\\r", or "\\n"')375+376+ // sameSite377+ expect(() => {378+ serialize('great_cookie', 'banana', { sameSite: 'Strict;evil' as 'Strict' })379+ }).toThrowError('sameSite must not contain ";", "\\r", or "\\n"')380+ expect(() => {381+ serialize('great_cookie', 'banana', { sameSite: 'Strict\revil' as 'Strict' })382+ }).toThrowError('sameSite must not contain ";", "\\r", or "\\n"')383+ expect(() => {384+ serialize('great_cookie', 'banana', { sameSite: 'Strict\nevil' as 'Strict' })385+ }).toThrowError('sameSite must not contain ";", "\\r", or "\\n"')386+387+ // priority388+ expect(() => {389+ serialize('great_cookie', 'banana', { priority: 'High;evil' as 'High' })390+ }).toThrowError('priority must not contain ";", "\\r", or "\\n"')391+ expect(() => {392+ serialize('great_cookie', 'banana', { priority: 'High\revil' as 'High' })393+ }).toThrowError('priority must not contain ";", "\\r", or "\\n"')394+ expect(() => {395+ serialize('great_cookie', 'banana', { priority: 'High\nevil' as 'High' })396+ }).toThrowError('priority must not contain ";", "\\r", or "\\n"')397 })398 399 it('Should throw Error for invalid cookie name', () => {400 expect(() => {27 unmodified linesmodified:src/utils/cookie.ts+1 added-1 removed
189 unmodified lines190 throw new Error('__Host- Cookie must not have Domain attributes')191 }192 }193 194- for (const key of ['domain', 'path'] as (keyof CookieOptions)[]) {194+ for (const key of ['domain', 'path', 'sameSite', 'priority'] as (keyof CookieOptions)[]) {195 if (opt[key] && /[;\r\n]/.test(opt[key] as string)) {196 throw new Error(`${key} must not contain ";", "\\r", or "\\n"`)197 }198 }76 unmodified lines