Read a byte-string token from the raw string As defined in RFC 4566 1*(%x01-09/%x0B-0C/%x0E-FF) ;any byte except NUL, CR, or LF we imply that extensions byte-string are UTF-8 encoded.
(raw string, start int)
| 1018 | // As defined in RFC 4566 1*(%x01-09/%x0B-0C/%x0E-FF) ;any byte except NUL, CR, or LF |
| 1019 | // we imply that extensions byte-string are UTF-8 encoded. |
| 1020 | func readCandidateByteString(raw string, start int) (string, int, error) { |
| 1021 | for i, char := range raw[start:] { |
| 1022 | if char == 0x20 { // SP |
| 1023 | return raw[start : start+i], start + i + 1, nil |
| 1024 | } |
| 1025 | |
| 1026 | // 1*(%x01-09/%x0B-0C/%x0E-FF) |
| 1027 | if (char < 0x01 || char > 0x09) && |
| 1028 | (char < 0x0B || char > 0x0C) && |
| 1029 | (char < 0x0E || char > 0xFF) { |
| 1030 | return "", 0, fmt.Errorf("invalid byte-string character: %c", char) //nolint: err113 // handled by caller |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | return raw[start:], len(raw), nil |
| 1035 | } |
| 1036 | |
| 1037 | // Read and validate raddr and rport from the raw string |
| 1038 | // [SP rel-addr] [SP rel-port] |
no test coverage detected
searching dependent graphs…