Skip to content

Commit

Permalink
Fixed removal of user info for URLs that contain encoded @ characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Lavamancer authored and microkatz committed Sep 12, 2024
1 parent f133e8d commit 17e0fd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static Uri removeUserInfo(Uri uri) {
}

// The Uri must include a "@" if the user info is non-null.
String authorityWithUserInfo = checkNotNull(uri.getAuthority());
String authorityWithUserInfo = checkNotNull(uri.getEncodedAuthority());
checkArgument(authorityWithUserInfo.contains("@"));
String authority = Util.split(authorityWithUserInfo, "@")[1];
return uri.buildUpon().encodedAuthority(authority).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ public void removeUserInfo_withNoUserInfo() {
.isEqualTo(Uri.parse("rtsp://foo.bar:5050/foo.mkv"));
}

@Test
public void removeUserInfo_withEncodedAtInUserInfo() {
Uri uri = Uri.parse("rtsp://user%40name:pass@foo.bar/foo.mkv");
assertThat(RtspMessageUtil.removeUserInfo(uri))
.isEqualTo(Uri.parse("rtsp://foo.bar/foo.mkv"));
}

@Test
public void parseContentLengthHeader_withContentLengthOver31Bits_succeeds() throws Exception {
String line = "Content-Length: 1000000000000000";
Expand Down

0 comments on commit 17e0fd2

Please sign in to comment.