Skip to content

Commit

Permalink
Handle RTSP session id properly.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
claincly authored and christosts committed Aug 5, 2021
1 parent 2946cbe commit a5cbd9f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public RtspAuthUserInfo(String username, String password) {
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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ public void serialize_failedResponse_succeeds() {
.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");
Expand Down

0 comments on commit a5cbd9f

Please sign in to comment.