Skip to content

fix: harden windows path normalization#197

Open
bmdavis419 wants to merge 1 commit intocodex/pr-c-searchpath-files-and-dirsfrom
codex/pr-g-windows-path-hardening
Open

fix: harden windows path normalization#197
bmdavis419 wants to merge 1 commit intocodex/pr-c-searchpath-files-and-dirsfrom
codex/pr-g-windows-path-hardening

Conversation

@bmdavis419
Copy link
Collaborator

@bmdavis419 bmdavis419 commented Feb 28, 2026

Summary

  • remove slash-assumption path checks for windows absolute paths
  • normalize windows separator handling in validation logic
  • add windows-focused test coverage

Issues

Greptile Summary

Fixed Windows path validation to properly handle both backslash and forward slash separators. The changes ensure that Windows paths like C:/path are correctly validated alongside C:\path.

Key Changes:

  • Updated path validation regex from /^[a-zA-Z]:\\/ to /^[a-zA-Z]:[\\/]/ to accept both separators
  • Improved telemetry path handling using path.join() and path.dirname() for cross-platform compatibility
  • Added test coverage for Windows paths with forward slashes

Impact:

  • LocalPath validation now correctly accepts C:/path (previously rejected)
  • SearchPath validation now correctly rejects C:/path as absolute (previously accepted due to bug)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes consistently fix Windows path validation across all affected files, add appropriate test coverage, and improve cross-platform path handling. The only behavioral change is correctly rejecting C:/path as search paths (which should be relative), fixing a previous validation bug.
  • No files require special attention

Important Files Changed

Filename Overview
apps/cli/src/lib/telemetry.ts Improved cross-platform path handling using path.join() and path.dirname(), renamed variable to avoid shadowing
apps/server/src/resources/schema.ts Updated Windows path regex to accept both backslash and forward slash separators after drive letter
apps/server/src/validation/index.ts Updated Windows path validation regex to handle both path separators consistently
apps/server/src/validation/index.test.ts Added test coverage for Windows paths with forward slashes in both local and search path validators

Last reviewed commit: 6b69419

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.

1 participant