Skip to content

Prevent CLI output from overwriting input - #55

Open
Ray0907 wants to merge 1 commit into
firecrawl:mainfrom
Ray0907:fix-cli-output-overwrites-input
Open

Prevent CLI output from overwriting input#55
Ray0907 wants to merge 1 commit into
firecrawl:mainfrom
Ray0907:fix-cli-output-overwrites-input

Conversation

@Ray0907

@Ray0907 Ray0907 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • reject --output paths that refer to the input file before conversion
  • compare both normalized paths and file identity to cover hard links and symlinks
  • add regression tests that verify the source bytes remain unchanged

Root cause

The CLI converted the document and passed --output directly to writeFile() without
checking whether it referred to the input. Using the same path, or an alias of it,
therefore replaced the source document with generated Markdown.

Impact

Invalid input/output combinations now fail with exit code 2 and leave the source file
untouched.

Validation

  • npm test (15 passed)
  • cargo test --locked (217 passed, 1 ignored)
  • direct-path and hard-link regression tests
  • symlink smoke test with matching source SHA-256 before and after rejection

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Ray0907
Ray0907 marked this pull request as ready for review August 7, 2026 09:39
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