From: Marcel van der Veldt Date: Mon, 10 Mar 2025 13:50:00 +0000 (+0100) Subject: Fix playlist parsing with parent folder references (#2019) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=f47c50ed805f7585927faf8da1db725ed2e59cf0;p=music-assistant-server.git Fix playlist parsing with parent folder references (#2019) If a playlist contains ../ parent references, auto resolve these --- 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)