Skip to content

Commit 0fa5a2b

Browse files
zahclaude
andauthored
fix(expand_archive): normalize backslashes on Windows in markerInsideDestination (#15)
The marker-inside-destination prefix check was skipping the backslash -> forward-slash canonicalisation when running on Windows (it was guarded by `when not defined(windows)`). The check then appended "/" to the destination before the prefix test: m.startsWith(d & "/") so a marker like `C:\actions-runner\config.cmd` was compared against `C:\actions-runner/` and rejected with expandArchive.build: marker 'C:\actions-runner\config.cmd' must live inside destination 'C:\actions-runner' The off-platform tests passed because their canonicalisation made everything forward-slashes; the on-Windows path silently broke every recipe that used backslash separators (which is basically every Windows recipe). Apply the same canonicalisation on every host. The existing test "marker inside destination on Windows-style paths" now actually exercises the Windows path (it always passed on Linux but would have failed on Windows pre-fix). Surfaced during L3 production-profile validation: with PRs #11 + #12 + #13 + #14 the profile-compile chain reached the run stage of system_windows_runner.nim, which calls expandArchive.build with `destination = C:\actions-runner` and `marker = C:\actions-runner\config.cmd`. That call now succeeds. --no-verify: pre-existing prek migration-mode failure (no .pre-commit-config.yaml in repo). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aa81dbd commit 0fa5a2b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

libs/repro_dsl_stdlib/src/repro_dsl_stdlib/packages/expand_archive.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ proc markerInsideDestination*(marker, destination: string): bool =
252252
if marker.len == 0 or destination.len == 0:
253253
return false
254254
proc canon(p: string): string =
255-
var lowered = p
256-
when not defined(windows):
257-
# On non-Windows hosts the input may still be a Windows-style
258-
# path (when the test fixture mirrors a Windows recipe). We
259-
# canonicalise backslash -> forward slash so the prefix check
260-
# is direction-agnostic; the path itself stays unevaluated
261-
# because we are not touching the filesystem here.
262-
lowered = lowered.replace("\\", "/")
263-
if lowered.len > 1 and lowered[^1] in {'/', '\\'}:
255+
# Canonicalise backslash -> forward slash on EVERY host. On non-Windows
256+
# the input may still be a Windows-style path (test fixture mirrors a
257+
# Windows recipe); on Windows the input may be either separator — and
258+
# the prefix check below appends "/", so leaving backslashes in place
259+
# made an in-destination marker like ``C:\foo\bar`` look outside
260+
# ``C:\foo``. The path itself stays unevaluated because we are not
261+
# touching the filesystem here.
262+
var lowered = p.replace("\\", "/")
263+
if lowered.len > 1 and lowered[^1] == '/':
264264
lowered.setLen(lowered.len - 1)
265265
lowered
266266
let m = canon(marker)

0 commit comments

Comments
 (0)