domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]
(value)
| 1581 | return True |
| 1582 | |
| 1583 | def get_domain_literal(value): |
| 1584 | """ domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS] |
| 1585 | |
| 1586 | """ |
| 1587 | domain_literal = DomainLiteral() |
| 1588 | if value[0] in CFWS_LEADER: |
| 1589 | token, value = get_cfws(value) |
| 1590 | domain_literal.append(token) |
| 1591 | if not value: |
| 1592 | raise errors.HeaderParseError("expected domain-literal") |
| 1593 | if value[0] != '[': |
| 1594 | raise errors.HeaderParseError("expected '[' at start of domain-literal " |
| 1595 | "but found '{}'".format(value)) |
| 1596 | value = value[1:] |
| 1597 | domain_literal.append(ValueTerminal('[', 'domain-literal-start')) |
| 1598 | if _check_for_early_dl_end(value, domain_literal): |
| 1599 | return domain_literal, value |
| 1600 | if value[0] in WSP: |
| 1601 | token, value = get_fws(value) |
| 1602 | domain_literal.append(token) |
| 1603 | token, value = get_dtext(value) |
| 1604 | domain_literal.append(token) |
| 1605 | if _check_for_early_dl_end(value, domain_literal): |
| 1606 | return domain_literal, value |
| 1607 | if value[0] in WSP: |
| 1608 | token, value = get_fws(value) |
| 1609 | domain_literal.append(token) |
| 1610 | if _check_for_early_dl_end(value, domain_literal): |
| 1611 | return domain_literal, value |
| 1612 | if value[0] != ']': |
| 1613 | raise errors.HeaderParseError("expected ']' at end of domain-literal " |
| 1614 | "but found '{}'".format(value)) |
| 1615 | domain_literal.append(ValueTerminal(']', 'domain-literal-end')) |
| 1616 | value = value[1:] |
| 1617 | if value and value[0] in CFWS_LEADER: |
| 1618 | token, value = get_cfws(value) |
| 1619 | domain_literal.append(token) |
| 1620 | return domain_literal, value |
| 1621 | |
| 1622 | def get_domain(value): |
| 1623 | """ domain = dot-atom / domain-literal / obs-domain |
no test coverage detected