(unparsedAttributes, cookieAttributeList = {})
| 62512 | return null; |
| 62513 | } |
| 62514 | return { |
| 62515 | name, |
| 62516 | value, |
| 62517 | ...parseUnparsedAttributes(unparsedAttributes) |
| 62518 | }; |
| 62519 | } |
| 62520 | function parseUnparsedAttributes(unparsedAttributes, cookieAttributeList = {}) { |
| 62521 | if (unparsedAttributes.length === 0) { |
| 62522 | return cookieAttributeList; |
| 62523 | } |
| 62524 | assert2(unparsedAttributes[0] === ";"); |
| 62525 | unparsedAttributes = unparsedAttributes.slice(1); |
| 62526 | let cookieAv = ""; |
| 62527 | if (unparsedAttributes.includes(";")) { |
| 62528 | cookieAv = collectASequenceOfCodePointsFast( |
| 62529 | ";", |
| 62530 | unparsedAttributes, |
| 62531 | { position: 0 } |
| 62532 | ); |
| 62533 | unparsedAttributes = unparsedAttributes.slice(cookieAv.length); |
| 62534 | } else { |
| 62535 | cookieAv = unparsedAttributes; |
| 62536 | unparsedAttributes = ""; |
| 62537 | } |
| 62538 | let attributeName = ""; |
| 62539 | let attributeValue = ""; |
| 62540 | if (cookieAv.includes("=")) { |
| 62541 | const position = { position: 0 }; |
| 62542 | attributeName = collectASequenceOfCodePointsFast( |
| 62543 | "=", |
| 62544 | cookieAv, |
| 62545 | position |
| 62546 | ); |
| 62547 | attributeValue = cookieAv.slice(position.position + 1); |
| 62548 | } else { |
| 62549 | attributeName = cookieAv; |
| 62550 | } |
| 62551 | attributeName = attributeName.trim(); |
| 62552 | attributeValue = attributeValue.trim(); |
| 62553 | if (attributeValue.length > maxAttributeValueSize) { |
| 62554 | return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList); |
| 62555 | } |
| 62556 | const attributeNameLowercase = attributeName.toLowerCase(); |
| 62557 | if (attributeNameLowercase === "expires") { |
| 62558 | const expiryTime = new Date(attributeValue); |
| 62559 | cookieAttributeList.expires = expiryTime; |
| 62560 | } else if (attributeNameLowercase === "max-age") { |
| 62561 | const charCode = attributeValue.charCodeAt(0); |
| 62562 | if ((charCode < 48 || charCode > 57) && attributeValue[0] !== "-") { |
| 62563 | return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList); |
| 62564 | } |
| 62565 | if (!/^\d+$/.test(attributeValue)) { |
| 62566 | return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList); |
| 62567 | } |
| 62568 | const deltaSeconds = Number(attributeValue); |
| 62569 | cookieAttributeList.maxAge = deltaSeconds; |
| 62570 | } else if (attributeNameLowercase === "domain") { |
| 62571 | let cookieDomain = attributeValue; |
no test coverage detected