From b00b4ac894d62aeaf2233717b63b5b38e3581e64 Mon Sep 17 00:00:00 2001 From: "Aratz M. Lasa" Date: Mon, 9 Dec 2019 22:58:29 +0100 Subject: [PATCH] Documented Transcoder functions, and fixed ip6zone string validation Documented Transcoder functions, and fixed ip6zone string validation --- transcoders.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/transcoders.go b/transcoders.go index e1f5b27..89da695 100644 --- a/transcoders.go +++ b/transcoders.go @@ -14,8 +14,11 @@ import ( ) type Transcoder interface { + // Validates and encodes to bytes a multiaddr that's in the string representation. StringToBytes(string) ([]byte, error) + // Validates and decodes to a string a multiaddr that's in the bytes representation. BytesToString([]byte) (string, error) + // Validates bytes when parsing a multiaddr that's already in the bytes representation. ValidateBytes([]byte) error } @@ -63,6 +66,9 @@ func ip6zoneStB(s string) ([]byte, error) { if len(s) == 0 { return nil, fmt.Errorf("empty ip6zone") } + if strings.Contains(s, "/") { + return nil, fmt.Errorf("IPv6 zone ID contains '/': %s", s) + } return []byte(s), nil }