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 Yusuke Wada · committed by GitHub · parent 48fa223 · Browse files · 2 files+16 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+16 added−0 removed

  • tests:+12 added−0 removed
  • other:+4 added−0 removed

2 files+16 added−0 removed

modified:src/utils/cookie.test.ts+12 added
292 unmodified lines
293 serialize('great_cookie', 'banana', { path: '/\nevil' })294 }).toThrowError('path must not contain ";", "\\r", or "\\n"')295 })296297 it('Should throw Error for invalid cookie name', () => {298 expect(() => {299 serialize('legit\r\nX-Injected: evil', 'value')300 }).toThrowError('Invalid cookie name')301 expect(() => {302 serialize('bad;name', 'value')303 }).toThrowError('Invalid cookie name')304 expect(() => {305 serialize('bad=name', 'value')306 }).toThrowError('Invalid cookie name')307 })308309 it('Should serialize cookie with lowercase priority values', () => {310 const lowSerialized = serialize('test_cookie', 'value', {311 priority: 'low',312 })
13 unmodified lines
modified:src/utils/cookie.ts+4 added
137 unmodified lines
138 return parsedCookie139}140141const _serialize = (name: string, value: string, opt: CookieOptions = {}): string => {142 if (!validCookieNameRegEx.test(name)) {143 throw new Error('Invalid cookie name')144 }145146 let cookie = `${name}=${value}`147148 if (name.startsWith('__Secure-') && !opt.secure) {149 // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-4.1.3.1
99 unmodified lines