From f47c50ed805f7585927faf8da1db725ed2e59cf0 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 10 Mar 2025 14:50:00 +0100 Subject: [PATCH] Fix playlist parsing with parent folder references (#2019) If a playlist contains ../ parent references, auto resolve these --- music_assistant/providers/filesystem_local/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/music_assistant/providers/filesystem_local/__init__.py b/music_assistant/providers/filesystem_local/__init__.py index d4c8a8c1..f8dad59e 100644 --- a/music_assistant/providers/filesystem_local/__init__.py +++ b/music_assistant/providers/filesystem_local/__init__.py @@ -766,12 +766,11 @@ class LocalFileSystemProvider(MusicProvider): # - relative to the playlist path with a leading slash for _line in (line, urllib.parse.unquote(line)): for filename in ( - # try to resolve the line as an absolute path - _line, - # try to resolve the line as a relative path to the playlist - os.path.join(playlist_path, _line.removeprefix("/")), - # try to resolve the line by resolving it against the absolute playlist path + # try to resolve the line by resolving it against the (absolute) playlist path + # use the path.resolve step in between to auto-resolve parent item references (Path(self.get_absolute_path(playlist_path)) / _line).resolve().as_posix(), + # try to resolve the line as a full absolute (or relative to music dir) path + _line, ): with contextlib.suppress(FileNotFoundError): file_item = await self.resolve(filename) -- 2.34.1