From 3b2fbf638f7589b451d668d9365afac3f877d1e2 Mon Sep 17 00:00:00 2001 From: Zaz Brown Date: Wed, 7 May 2025 13:53:14 +0100 Subject: [PATCH 1/2] fix: only recognize `_tops/`, not `_tops/` Avoids IndexError from `relpath[1]`. Fixes #9949. --- _utils/toputils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_utils/toputils.py b/_utils/toputils.py index f589339..0293277 100644 --- a/_utils/toputils.py +++ b/_utils/toputils.py @@ -332,7 +332,7 @@ def toppath(self, path, saltenv=None, verify=True): except SaltRenderError: return '' - if relpath.startswith(self.topd_directory): # pylint: disable=E1101 + if relpath.startswith(self.topd_directory + os.sep): # pylint: disable=E1101 relpath = relpath.split(self.topd_directory + os.sep)[ 1 ] # pylint: disable=E1101 From bc060b2d438f74ef41cce1498d5b310cf25bc78c Mon Sep 17 00:00:00 2001 From: Zaz Brown Date: Fri, 9 May 2025 20:51:22 +0100 Subject: [PATCH 2/2] fix: recognize paths even if they contain `_tops/` Previously, `_tops/this_is_not_tops/test.top` would result in a relpath of `_tops/this_is_not` (cut off in the middle of a directory name). --- _utils/toputils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_utils/toputils.py b/_utils/toputils.py index 0293277..0d58cba 100644 --- a/_utils/toputils.py +++ b/_utils/toputils.py @@ -333,7 +333,7 @@ def toppath(self, path, saltenv=None, verify=True): return '' if relpath.startswith(self.topd_directory + os.sep): # pylint: disable=E1101 - relpath = relpath.split(self.topd_directory + os.sep)[ + relpath = relpath.split(self.topd_directory + os.sep, maxsplit=1)[ 1 ] # pylint: disable=E1101