Skip to content

Commit 8ce1389

Browse files
committed
Fixed removal of user info for URLs that contain encoded @ characters
1 parent 08993b6 commit 8ce1389

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMessageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public static Uri removeUserInfo(Uri uri) {
194194
}
195195

196196
// The Uri must include a "@" if the user info is non-null.
197-
String authorityWithUserInfo = checkNotNull(uri.getAuthority());
197+
String authorityWithUserInfo = checkNotNull(uri.getEncodedAuthority());
198198
checkArgument(authorityWithUserInfo.contains("@"));
199199
String authority = Util.split(authorityWithUserInfo, "@")[1];
200200
return uri.buildUpon().encodedAuthority(authority).build();

‎libraries/exoplayer_rtsp/src/test/java/androidx/media3/exoplayer/rtsp/RtspMessageUtilTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ public void removeUserInfo_withNoUserInfo() {
449449
.isEqualTo(Uri.parse("rtsp://foo.bar:5050/foo.mkv"));
450450
}
451451

452+
@Test
453+
public void removeUserInfo_withEncodedAtInUserInfo() {
454+
Uri uri = Uri.parse("rtsp://user%40name:pass@foo.bar/foo.mkv");
455+
assertThat(RtspMessageUtil.removeUserInfo(uri))
456+
.isEqualTo(Uri.parse("rtsp://foo.bar/foo.mkv"));
457+
}
458+
452459
@Test
453460
public void parseContentLengthHeader_withContentLengthOver31Bits_succeeds() throws Exception {
454461
String line = "Content-Length: 1000000000000000";

0 commit comments

Comments
 (0)