From bdb23b0bf40040817d7764a0a3d05b1e5b33f86a Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Sat, 25 Dec 2021 22:39:19 -0500 Subject: [PATCH] Improve parsing candidates with missing Foundation Support missing foundation candidates with additional attributes Resolves #390 --- candidate_base.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/candidate_base.go b/candidate_base.go index 230bde8..7703e71 100644 --- a/candidate_base.go +++ b/candidate_base.go @@ -424,11 +424,11 @@ func (c *candidateBase) Marshal() string { // UnmarshalCandidate creates a Candidate from its string representation func UnmarshalCandidate(raw string) (Candidate, error) { split := strings.Fields(raw) - switch { // Foundation not specified: not RFC 8445 compliant but seen in the wild - case len(split) == 7 && raw[0] == ' ': + if len(raw) != 0 && raw[0] == ' ' { split = append([]string{" "}, split...) - case len(split) < 8: + } + if len(split) < 8 { return nil, fmt.Errorf("%w (%d)", errAttributeTooShortICECandidate, len(split)) }