musikr: pin dotdot resolution of playlist entries

This commit is contained in:
jay
2026-11-12 17:58:58 -05:00
parent e206acde3f
commit 18fde00a41
@@ -94,6 +94,40 @@ class PlaylistPathResolverTest {
)
}
@Test
fun resolve_dotdotEntries_escapeThePlaylistDirectory() {
val volume = FakeVolume()
val playlistDir = Path(volume, Components.parseUnix("Music/Playlists"))
val musicRoot = Path(volume, Components.parseUnix("Music"))
val library =
setOf(
Path(volume, Components.parseUnix("Music/Library/Artist/a.mp3")),
Path(volume, Components.parseUnix("Music/Library/Artist/b.mp3")),
)
val entries =
listOf(
PlaylistPathResolver.Entry(
Components.parseUnix("../Library/Artist/a.mp3"), absolute = false
),
PlaylistPathResolver.Entry(
Components.parseUnix("../Library/Artist/b.mp3"), absolute = false
),
)
val resolved =
PlaylistPathResolver().resolve(entries, listOf(playlistDir, musicRoot)) {
it in library
}
assertEquals(
listOf(
Path(volume, Components.parseUnix("Music/Library/Artist/a.mp3")),
Path(volume, Components.parseUnix("Music/Library/Artist/b.mp3")),
),
resolved,
)
}
private class FakeVolume : Volume.External {
override val mediaStoreName = "fake"
override val id = "fake"