Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,34 +873,7 @@ func unmarshalMediaDescription(lex *lexer) (stateFn, error) { //nolint:cyclop
if err != nil {
return nil, err
}

// Set according to currently registered with IANA
// https://tools.ietf.org/html/rfc4566#section-5.14
// https://tools.ietf.org/html/rfc4975#section-8.1
for _, proto := range strings.Split(field, "/") {
if !anyOf(
proto,
"UDP",
"RTP",
"AVP",
"SAVP",
"SAVPF",
"TLS",
"DTLS",
"SCTP",
"AVPF",
"TCP",
"MSRP",
"BFCP",
"UDT",
"IX",
"MRCPv2",
"FEC",
) {
return nil, fmt.Errorf("%w `%v`", errSDPInvalidNumericValue, field)
}
newMediaDesc.MediaName.Protos = append(newMediaDesc.MediaName.Protos, proto)
}
newMediaDesc.MediaName.Protos = strings.Split(field, "/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can leave a comment about why we made this choice or a link to this PR so people who look through the source code can find out why we would prefer to be more liberal for inputs? Although it can make sense for us internally, external users may have a harder time searching for the reasoning.


// <fmt>...
for {
Expand Down
13 changes: 0 additions & 13 deletions unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1812,19 +1812,6 @@ func TestUnmarshalMediaDescription_SetsPortRange(t *testing.T) {
}
}

func TestUnmarshalMediaDescription_Error_InvalidProto(t *testing.T) {
// proto token not in the allowed list
l := &lexer{
desc: &SessionDescription{},
cache: &unmarshalCache{},
baseLexer: baseLexer{value: "audio 9 WRONG/PROTO 0\r\n"},
}

st, err := unmarshalMediaDescription(l)
assert.Nil(t, st)
assert.ErrorIs(t, err, errSDPInvalidNumericValue)
}

func TestUnmarshalMediaTitle_Error_ReadLine(t *testing.T) {
// empty input
l := &lexer{
Expand Down
Loading