Skip to content

fix(pampa): normalize resolve_path output to forward slashes#340

Merged
cscheid merged 2 commits into
mainfrom
bugfix/bd-picv-fix-windows-path-separator
Jun 26, 2026
Merged

fix(pampa): normalize resolve_path output to forward slashes#340
cscheid merged 2 commits into
mainfrom
bugfix/bd-picv-fix-windows-path-separator

Conversation

@cderv

@cderv cderv commented Jun 25, 2026

Copy link
Copy Markdown
Member

On Windows, quarto.utils.resolve_path joins the script directory with the requested path via Path::join, so the Lua-visible result carries native backslash separators (C:\ext\dir\data.json). The native render path is unaffected — the consumers (io.open, fs::read via mediabag.fetch, dofile) all accept backslashes on Windows — but the cosmetic separator difference breaks ~10 path assertions in quarto_api.rs that hardcode forward slashes.

Investigating the separator handling surfaced a second, latent bug: resolve_path gated on Path::is_absolute(). On wasm32 (and on Windows for a drive-less rooted path like /project/x), is_absolute() returns false, so a rooted VFS path would fall through and wrongly join onto the script dir. bd-vxl8 already swept io_wasm.rs / dofile_wasm.rs from is_absolute/starts_with('/') to quarto_util::is_rooted; resolve_path was missed. No current caller passes a rooted path here, so it is latent today — but a real convention divergence.

Fix

Normalize on the production side rather than cfg-gating the test expectations:

  • Swap is_absolute() for quarto_util::is_rooted() (= has_root(), correct on both native and WASM).
  • Run every return path through quarto_util::to_forward_slashes, establishing a single invariant: resolve_path always returns forward slashes.

This matches the boundary-normalization precedent set by bd-vxl8 and quarto-cli's pathWithForwardSlashes convention, and lets the tests assert forward slashes on all platforms with no #[cfg(windows)] duplication.

The behavior change is low-risk: output goes from backslash to forward-slash on Windows, and all known consumers accept forward slashes there. WASM already produced forward slashes and is unaffected. The is_rooted swap is behavior-neutral today and forward-compatible for a future WASM caller passing a /project/... path.

Two new tests pin the contract: resolve_path returns forward slashes when the pushed script dir itself carries backslashes (the real filter.rs / shortcode.rs input on Windows), and a rooted input is returned as-is and never joined onto an active script dir.

Strand: bd-picv

cderv added 2 commits June 24, 2026 19:19
resolve_path joined the script dir with Path::join and returned the
native string, so on Windows extension authors saw backslash paths
(C:\ext\dir\data.json). The output feeds io.open/dofile/mediabag.fetch,
which tolerate backslashes natively, so this was cosmetic on native —
but it diverged from the pathWithForwardSlashes convention the rest of
the tree already follows (quarto-util::to_forward_slashes, established
by bd-vxl8) and left the path-comparison tests platform-dependent.

normalize_path and the rooted/no-script-dir return paths now go through
to_forward_slashes, so resolve_path returns forward slashes on every
platform — one invariant, no cfg-gated test expectations.

Also swap the is_absolute() gate for quarto_util::is_rooted(). is_absolute
returns false on wasm32 for /project VFS paths and on Windows for
drive-less rooted paths, which would let such a path fall through and
wrongly join onto the script dir. No current caller passes an absolute
path here, so this is behavior-neutral today but closes the latent WASM
mis-join and matches the is_rooted convention bd-vxl8 set in the io/dofile
WASM paths.
@cscheid cscheid merged commit b8fb38b into main Jun 26, 2026
5 checks passed
@cscheid cscheid deleted the bugfix/bd-picv-fix-windows-path-separator branch June 26, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants