Treat backslash as a path separator in XModem filename validation#11085
Conversation
isValidFilename split components on forward slash only, so backslash separated components were not examined individually. Use strpbrk to split on both, and reject drive qualified names. The native Windows daemon build maps FSCom to PortduinoFS on the host filesystem, where both separators are significant. Adds test coverage for backslash and drive qualified inputs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughXModem filename validation rejects drive-qualified paths and detects ChangesXModem filename validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/xmodem.cpp`:
- Around line 65-66: Restrict the drive-prefix rejection in the filename
validator to cases where name[0] is an ASCII letter and name[1] is ':',
preserving other colon-containing filenames. In test/test_xmodem/test_main.cpp
lines 33-38, add a positive regression assertion confirming a non-drive colon
filename is accepted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 29c19157-a223-4601-ac24-38ef1f3d7623
📒 Files selected for processing (2)
src/xmodem.cpptest/test_xmodem/test_main.cpp
Only [A-Za-z] can begin a drive qualifier, so rejecting on the colon alone also refused legal POSIX filenames such as 1:30pm.txt.
⚡ Try this PR in the Web FlasherNote Building this pull request… the flash button, badges and supported-board |
isValidFilenameinsrc/xmodem.cppsplit path components on/only. Backslash separated components were therefore evaluated as a single component, and drive qualified names were not considered at all.This is portable behaviour on the embedded targets, where the filesystem only recognises
/. It matters for the native daemon:FSCommon.hmapsFSComtoPortduinoFSunderARCH_PORTDUINO, so filenames reach the host filesystem, and the Windows build added in #11031 runs on a host where both separators are significant.Changes:
strpbrk(seg, "/\\")so/and\are both treated as separators.C:\dir\file, which the component loop alone would not catch.test/test_xmodemwith backslash, mixed separator, and drive qualified cases.Existing accepted forms are unchanged: absolute paths, subdirectories, and names that merely contain dots (
my..file,...) still pass.native-windowstest_xmodempasses, 5 of 5 cases. Other suites were not run locally.Summary by CodeRabbit
C:\...,C:/...,c:relative.txt).