Handle RTSP session id properly.

Issue: #9254

#minor-release

We used to allow only alphanumerical characters in session id. The spec also
allows "$", "-", "_", ".", "+" (RFC2326 Sections 3.4 and 15.1).

PiperOrigin-RevId: 388873742
This commit is contained in:
claincly 2021-08-05 08:40:00 +01:00 committed by Christos Tsilopoulos
parent 2946cbe190
commit a5cbd9f6c2
3 changed files with 13 additions and 2 deletions

View File

@ -142,6 +142,8 @@
([#9182](https://github.com/google/ExoPlayer/issues/9182)).
* Handle an extra semicolon in SDP fmtp attribute
([#9247](https://github.com/google/ExoPlayer/pull/9247)).
* Fix handling of special characters in the RTSP session ID
([#9254](https://github.com/google/ExoPlayer/issues/9254)).
* MediaSession extension:
* Deprecate `setControlDispatcher` in `MediaSessionConnector`. The
`ControlDispatcher` parameter has also been deprecated in all

View File

@ -92,9 +92,9 @@ import java.util.regex.Pattern;
private static final Pattern CONTENT_LENGTH_HEADER_PATTERN =
Pattern.compile("Content-Length:\\s?(\\d+)", CASE_INSENSITIVE);
// Session header pattern, see RFC2326 Section 12.37.
// Session header pattern, see RFC2326 Sections 3.4 and 12.37.
private static final Pattern SESSION_HEADER_PATTERN =
Pattern.compile("(\\w+)(?:;\\s?timeout=(\\d+))?");
Pattern.compile("([\\w$-_.+]+)(?:;\\s?timeout=(\\d+))?");
// WWW-Authenticate header pattern, see RFC2068 Sections 14.46 and RFC2069.
private static final Pattern WWW_AUTHENTICATION_HEADER_DIGEST_PATTERN =

View File

@ -350,6 +350,15 @@ public final class RtspMessageUtilTest {
.isEqualTo(expectedRtspMessage.getBytes(RtspMessageChannel.CHARSET));
}
@Test
public void parseSessionHeader_withSessionIdContainingSpecialCharacters_succeeds()
throws Exception {
String sessionHeaderString = "610a63df-9b57.4856_97ac$665f+56e9c04";
RtspMessageUtil.RtspSessionHeader sessionHeader =
RtspMessageUtil.parseSessionHeader(sessionHeaderString);
assertThat(sessionHeader.sessionId).isEqualTo("610a63df-9b57.4856_97ac$665f+56e9c04");
}
@Test
public void removeUserInfo_withUserInfo() {
Uri uri = Uri.parse("rtsp://user:pass@foo.bar/foo.mkv");