Fixed removal of user info for URLs that contain encoded @ characters

This commit is contained in:
Lavamancer 2024-02-28 17:24:29 +01:00 committed by microkatz
parent f133e8d1f2
commit 17e0fd22b1
2 changed files with 8 additions and 1 deletions

View File

@ -192,7 +192,7 @@ import java.util.regex.Pattern;
}
// 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();

View File

@ -449,6 +449,13 @@ public final class RtspMessageUtilTest {
.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";