Fix RTSP session header parsing regex error.

Issue: #9416

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

#minor-release

PiperOrigin-RevId: 395909845
This commit is contained in:
claincly 2021-09-10 13:53:40 +01:00 committed by Oliver Woodman
parent 9f3c2fb5e1
commit 4f06419334
3 changed files with 13 additions and 1 deletions

View File

@ -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)).

View File

@ -94,7 +94,7 @@ import java.util.regex.Pattern;
// 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

@ -406,6 +406,16 @@ public final class RtspMessageUtilTest {
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");