Skip to content

fix(windows): block reserved names in tools#18076

Open
applerom wants to merge 1 commit intoanomalyco:devfrom
applerom:fix/windows-nul-minimal
Open

fix(windows): block reserved names in tools#18076
applerom wants to merge 1 commit intoanomalyco:devfrom
applerom:fix/windows-nul-minimal

Conversation

@applerom
Copy link

Issue for this PR

Fixes #13369

Type of change

  • Bug fix
  • Refactor / code improvement
  • New feature
  • Documentation

What does this PR do?

This fixes a native Windows footgun around reserved device names.

It rejects reserved Windows basenames like NUL, CON, PRN, AUX, COM1-COM9, and LPT1-LPT9 in the write, edit, and patch flows so those tools fail early instead of creating paths that Windows treats specially.

It also adds a narrow bash-side guard for literal reserved-name redirect targets when the bash tool is running through a POSIX shell on Windows (for example Git Bash). This covers the observed >NUL case that can create an undeletable artifact on native Windows.

The bash change is intentionally limited to literal redirect targets. It does not try to evaluate full dynamic shell expansion semantics.

How did you verify your code works?

I tested this locally on native Windows after rebasing onto the latest dev.

Commands run:

  • bun test test/tool/bash.test.ts test/tool/apply_patch.test.ts test/tool/edit.test.ts test/tool/write.test.ts
  • bun test test/util/filesystem.test.ts --test-name-pattern "Windows reserved names"

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Reject reserved Windows device basenames in file-writing and patch flows, and prevent literal reserved-name redirects like  when the bash tool runs in a POSIX shell on Windows. This keeps the fix scoped to the observed Windows/Git Bash artifact without trying to model full shell expansion semantics.
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found related PRs that address similar Windows reserved names issues:

  1. PR fix: prevent Windows reserved device names from being added to directory checks and simplify bash description parameter #11605 - "fix: prevent Windows reserved device names from being added to directory checks and simplify bash description parameter"

    • This appears to be an earlier attempt at addressing Windows reserved device names
  2. PR fix: prevent undeletable nul file on Windows #13406 - "fix: prevent undeletable nul file on Windows"

    • Directly related to the >NUL issue mentioned in the current PR
  3. PR fix: Windows CLI and deep link issues (#11657, #11666, #11674) #11724 - "fix: Windows CLI and deep link issues (Windows: opencode CLI hangs at startup when running internal npm list / npm config get registry #11657, [Windows] Opening with deep link duplicates projects #11666, [BUG]: (app): Clicking on overflowed tab on the right in the file view/review section does not scroll it into view #11674)"

    • General Windows-related fixes that may overlap with reserved names handling

These PRs suggest there have been previous efforts to address Windows reserved name issues. You should verify whether PR #11605 and #13406 were already merged or closed, and whether this PR (18076) is intended to supersede or complement them.

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.

Undeletable nul file

1 participant