Skip to content

Commit

Permalink
Fix RTSP session header parsing regex error.
Browse files Browse the repository at this point in the history
Issue: #9416

The dash "-" in the brackets must be escaped, or it acts like a range operator.

#minor-release

PiperOrigin-RevId: 395909845
  • Loading branch information
claincly authored and ojw28 committed Sep 10, 2021
1 parent 9f3c2fb commit 4f06419
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
([#9379](https://github.com/google/ExoPlayer/issues/9379)).
* Handle partial URIs in RTP-Info headers
([#9346](https://github.com/google/ExoPlayer/issues/9346)).
* Fix RTSP Session header handling
([#9416](https://github.com/google/ExoPlayer/issues/9416)).
* Extractors:
* ID3: Fix issue decoding ID3 tags containing UTF-16 encoded strings
([#9087](https://github.com/google/ExoPlayer/issues/9087)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public RtspAuthUserInfo(String username, String password) {

// 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 @@ -406,6 +406,16 @@ public void parseSessionHeader_withSessionIdContainingSpecialCharacters_succeeds
assertThat(sessionHeader.sessionId).isEqualTo("610a63df-9b57.4856_97ac$665f+56e9c04");
}

@Test
public void parseSessionHeader_withSessionIdContainingSpecialCharactersAndTimeout_succeeds()
throws Exception {
String sessionHeaderString = "610a63df-9b57.4856_97ac$665f+56e9c04;timeout=60";
RtspMessageUtil.RtspSessionHeader sessionHeader =
RtspMessageUtil.parseSessionHeader(sessionHeaderString);
assertThat(sessionHeader.sessionId).isEqualTo("610a63df-9b57.4856_97ac$665f+56e9c04");
assertThat(sessionHeader.timeoutMs).isEqualTo(60_000);
}

@Test
public void removeUserInfo_withUserInfo() {
Uri uri = Uri.parse("rtsp://user:pass@foo.bar/foo.mkv");
Expand Down

0 comments on commit 4f06419

Please sign in to comment.