(unparsedAttributes, cookieAttributeList = {})
| 16674 | } |
| 16675 | } |
| 16676 | } |
| 16677 | function validateCookieValue(value) { |
| 16678 | let len = value.length; |
| 16679 | let i = 0; |
| 16680 | if (value[0] === '"') { |
| 16681 | if (len === 1 || value[len - 1] !== '"') { |
| 16682 | throw new Error("Invalid cookie value"); |
| 16683 | } |
| 16684 | --len; |
| 16685 | ++i; |
| 16686 | } |
| 16687 | while (i < len) { |
| 16688 | const code = value.charCodeAt(i++); |
| 16689 | if (code < 33 || // exclude CTLs (0-31) |
| 16690 | code > 126 || // non-ascii and DEL (127) |
| 16691 | code === 34 || // " |
| 16692 | code === 44 || // , |
| 16693 | code === 59 || // ; |
| 16694 | code === 92) { |
| 16695 | throw new Error("Invalid cookie value"); |
| 16696 | } |
| 16697 | } |
| 16698 | } |
| 16699 | function validateCookiePath(path4) { |
| 16700 | for (let i = 0; i < path4.length; ++i) { |
| 16701 | const code = path4.charCodeAt(i); |
| 16702 | if (code < 32 || // exclude CTLs (0-31) |
| 16703 | code > 126 || // exclude DEL and non-ascii |
| 16704 | code === 59) { |
| 16705 | throw new Error("Invalid cookie path"); |
| 16706 | } |
| 16707 | } |
| 16708 | } |
| 16709 | function isLetterOrDigit(code) { |
| 16710 | return code >= 48 && code <= 57 || // 0-9 |
| 16711 | code >= 65 && code <= 90 || // A-Z |
| 16712 | code >= 97 && code <= 122; |
| 16713 | } |
| 16714 | function validateCookieDomain(domain) { |
| 16715 | if (domain === " ") { |
| 16716 | return; |
| 16717 | } |
| 16718 | if (domain.length > 255) { |
| 16719 | throw new Error("Invalid cookie domain"); |
| 16720 | } |
| 16721 | let labelLength = 0; |
| 16722 | for (let i = 0; i < domain.length; ++i) { |
| 16723 | const code = domain.charCodeAt(i); |
| 16724 | if (code === 46) { |
| 16725 | if (labelLength === 0) { |
| 16726 | throw new Error("Invalid cookie domain"); |
| 16727 | } |
| 16728 | if (domain.charCodeAt(i - 1) === 45) { |
| 16729 | throw new Error("Invalid cookie domain"); |
| 16730 | } |
| 16731 | labelLength = 0; |
| 16732 | continue; |
| 16733 | } |
no test coverage detected