Accept session names of "s= " in SDP.

RFC4566 says to use this if a session has no meaningful name. But we
were rejecting it due to another rule that says "whitespace MUST NOT be
used on either side of the = sign".

Bug: chromium:590625
Change-Id: I5d632f2cb371060adee794febe19bdfe76cb20ed
Reviewed-on: https://webrtc-review.googlesource.com/70262
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22887}
This commit is contained in:
Taylor Brandstetter 2018-04-16 10:45:24 -07:00 committed by Commit Bot
parent c0597fb382
commit 93a7b2470f
2 changed files with 17 additions and 3 deletions

View File

@ -457,10 +457,15 @@ static bool GetLine(const std::string& message,
// where <type> MUST be exactly one case-significant character and
// <value> is structured text whose format depends on <type>.
// 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;
}

View File

@ -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));
}