(cookie)
| 16571 | throw new Error("Invalid cookie value"); |
| 16572 | } |
| 16573 | --len; |
| 16574 | ++i; |
| 16575 | } |
| 16576 | while (i < len) { |
| 16577 | const code = value.charCodeAt(i++); |
| 16578 | if (code < 33 || // exclude CTLs (0-31) |
| 16579 | code > 126 || // non-ascii and DEL (127) |
| 16580 | code === 34 || // " |
| 16581 | code === 44 || // , |
| 16582 | code === 59 || // ; |
| 16583 | code === 92) { |
| 16584 | throw new Error("Invalid cookie value"); |
| 16585 | } |
| 16586 | } |
| 16587 | } |
| 16588 | function validateCookiePath(path4) { |
| 16589 | for (let i = 0; i < path4.length; ++i) { |
| 16590 | const code = path4.charCodeAt(i); |
| 16591 | if (code < 32 || // exclude CTLs (0-31) |
| 16592 | code > 126 || // exclude DEL and non-ascii |
| 16593 | code === 59) { |
| 16594 | throw new Error("Invalid cookie path"); |
| 16595 | } |
| 16596 | } |
| 16597 | } |
| 16598 | function isLetterOrDigit(code) { |
| 16599 | return code >= 48 && code <= 57 || // 0-9 |
| 16600 | code >= 65 && code <= 90 || // A-Z |
| 16601 | code >= 97 && code <= 122; |
| 16602 | } |
| 16603 | function validateCookieDomain(domain) { |
| 16604 | if (domain === " ") { |
| 16605 | return; |
| 16606 | } |
| 16607 | if (domain.length > 255) { |
| 16608 | throw new Error("Invalid cookie domain"); |
| 16609 | } |
| 16610 | let labelLength = 0; |
| 16611 | for (let i = 0; i < domain.length; ++i) { |
| 16612 | const code = domain.charCodeAt(i); |
| 16613 | if (code === 46) { |
| 16614 | if (labelLength === 0) { |
| 16615 | throw new Error("Invalid cookie domain"); |
| 16616 | } |
| 16617 | if (domain.charCodeAt(i - 1) === 45) { |
| 16618 | throw new Error("Invalid cookie domain"); |
| 16619 | } |
| 16620 | labelLength = 0; |
| 16621 | continue; |
| 16622 | } |
| 16623 | if (labelLength === 0 && !isLetterOrDigit(code)) { |
no test coverage detected