diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc index 2c34728917..f92baa1873 100644 --- a/pc/webrtcsdp.cc +++ b/pc/webrtcsdp.cc @@ -457,10 +457,15 @@ static bool GetLine(const std::string& message, // where MUST be exactly one case-significant character and // is structured text whose format depends on . // Whitespace MUST NOT be used on either side of the "=" sign. - if (line->length() < 3 || - !islower(cline[0]) || + // + // However, an exception to the whitespace rule is made for "s=", since + // RFC4566 also says: + // + // If a session has no meaningful name, the value "s= " SHOULD be used + // (i.e., a single space as the session name). + if (line->length() < 3 || !islower(cline[0]) || cline[1] != kSdpDelimiterEqual || - cline[2] == kSdpDelimiterSpace) { + (cline[0] != kLineTypeSessionName && cline[2] == kSdpDelimiterSpace)) { *pos = line_begin; return false; } diff --git a/pc/webrtcsdp_unittest.cc b/pc/webrtcsdp_unittest.cc index 7a974c49f3..0ff5249738 100644 --- a/pc/webrtcsdp_unittest.cc +++ b/pc/webrtcsdp_unittest.cc @@ -3758,3 +3758,12 @@ TEST_F(WebRtcSdpTest, SerializeAndDeserializeWithConnectionAddress) { EXPECT_EQ(video_desc_->connection_address().ToString(), video_desc->connection_address().ToString()); } + +// RFC4566 says "If a session has no meaningful name, the value "s= " SHOULD be +// used (i.e., a single space as the session name)." So we should accept that. +TEST_F(WebRtcSdpTest, DeserializeEmptySessionName) { + JsepSessionDescription jsep_desc(kDummyType); + std::string sdp = kSdpString; + Replace("s=-\r\n", "s= \r\n", &sdp); + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); +}