upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:15:26 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:15:26 -0500
commite5748d7384a32d631aa3473e7947bd5a6d88d69e (patch)
treebf499a2ad07f21013c62f55f2480f4034521c40e
parentc77e9403a3343f3b3fbd8fb6a1b1520788722653 (diff)
parenta90f221a7de1a6dafcaa1f36cf68c7eaf2fd1baa (diff)
Merge pull request #3173 from Marco Luzzaro
-rw-r--r--tests/test_navmesh_index.py2
-rw-r--r--tools/navmesh_index.py15
2 files changed, 8 insertions, 9 deletions
diff --git a/tests/test_navmesh_index.py b/tests/test_navmesh_index.py
index 2f040c958..212416087 100644
--- a/tests/test_navmesh_index.py
+++ b/tests/test_navmesh_index.py
@@ -244,7 +244,7 @@ class NavmeshIndexTest(unittest.TestCase):
244 carved = os.path.join(folder, "page.bin") 244 carved = os.path.join(folder, "page.bin")
245 with open(carved, "wb") as f: 245 with open(carved, "wb") as f:
246 f.write(page(pages=4)) 246 f.write(page(pages=4))
247 linked = os.path.join(folder, "report.json") 247 linked = os.path.join(self.root, "report.json")
248 try: 248 try:
249 os.link(carved, linked) 249 os.link(carved, linked)
250 except (OSError, NotImplementedError) as e: 250 except (OSError, NotImplementedError) as e:
diff --git a/tools/navmesh_index.py b/tools/navmesh_index.py
index 861c186e6..0ee070efa 100644
--- a/tools/navmesh_index.py
+++ b/tools/navmesh_index.py
@@ -275,6 +275,7 @@ def is_scanned_input(path, input_path, pattern):
275 return True 275 return True
276 if not os.path.isdir(input_path) or not os.path.isfile(path): 276 if not os.path.isdir(input_path) or not os.path.isfile(path):
277 return False 277 return False
278 pattern = pattern or "*.bin"
278 # Walk up from the report path and compare each folder like same_report_path does (normcase, realpath, 279 # Walk up from the report path and compare each folder like same_report_path does (normcase, realpath,
279 # samefile), so a spelling that differs only in case, or goes through a link, is still inside the input. 280 # samefile), so a spelling that differs only in case, or goes through a link, is still inside the input.
280 target = os.path.abspath(path) 281 target = os.path.abspath(path)
@@ -282,15 +283,13 @@ def is_scanned_input(path, input_path, pattern):
282 while not same_report_path(root, input_path): 283 while not same_report_path(root, input_path):
283 parent = os.path.dirname(root) 284 parent = os.path.dirname(root)
284 if parent == root: 285 if parent == root:
285 return False 286 break
286 root = parent 287 root = parent
287 pattern = pattern or "*.bin" 288 else:
288 if (fnmatch.fnmatch(os.path.relpath(target, root), pattern) 289 if (fnmatch.fnmatch(os.path.relpath(target, root), pattern)
289 or fnmatch.fnmatch(os.path.basename(target), pattern)): 290 or fnmatch.fnmatch(os.path.basename(target), pattern)):
290 return True 291 return True
291 # The spelling may not match while the file is still one the scan reads: fnmatch folds case only on Windows, 292 # A different spelling or a hard link anywhere can still refer to a scanned file.
292 # so CARVE/PAGE.BIN on a case-insensitive macOS or Linux volume, or a hard link, slips past the pattern. Ask
293 # the scan's own glob whether any file it reads is this one.
294 return any(same_report_path(target, scanned) 293 return any(same_report_path(target, scanned)
295 for scanned in glob.iglob( 294 for scanned in glob.iglob(
296 os.path.join(glob.escape(os.fspath(input_path)), "**", pattern), recursive=True)) 295 os.path.join(glob.escape(os.fspath(input_path)), "**", pattern), recursive=True))