feat: add file drag-and-drop support for images and PDFs#1658
Open
ambigois wants to merge 1 commit intodocker:mainfrom
Open
feat: add file drag-and-drop support for images and PDFs#1658ambigois wants to merge 1 commit intodocker:mainfrom
ambigois wants to merge 1 commit intodocker:mainfrom
Conversation
83267b5 to
d7860a9
Compare
Member
|
/review |
d7860a9 to
ab3a8d0
Compare
Author
|
/review |
598f53e to
fe3db9b
Compare
Author
|
/review |
- Add ParsePastedFiles() to detect file paths from paste events - Support Unix (space-separated with escaping) and Windows (quoted) formats - Validate file types (PNG, JPG, GIF, WebP, BMP, SVG, PDF) - Enforce 5MB size limit per file (>= boundary) - Add visual file type indicators with emoji icons - Integrate with existing attachment system - Handle edge cases (null chars, trailing backslash, etc.) - Add comprehensive test coverage Security hardening: - Add validateFilePath() to reject path traversal (..) and symlinks - Check for '..' BEFORE filepath.Clean() to prevent bypass - Use os.Lstat() instead of os.Stat() in all file validation paths - Return errors from addFileAttachment() and AttachFile() - Return error notification on failed attach instead of opening file picker - Eliminate TOCTOU by removing redundant allFilesValid() pre-check; AttachFile() is the single validation point with rollback on failure - Strip trailing backslash as malformed input - Add TestValidateFilePath, TestValidateFilePath_TraversalBeforeClean, and TestAddFileAttachment_SizeLimit Assisted-By: cagent
fe3db9b to
1d6cd30
Compare
Member
|
/review |
There was a problem hiding this comment.
Review Summary
Assessment: 🟢 APPROVE
This PR adds comprehensive file drag-and-drop support for images and PDFs with proper validation and testing. The implementation includes:
- Robust path parsing: Character-by-character state machine parsers for both Windows (quoted paths) and Unix (escaped paths) formats
- Type validation: Extension-based file type checking without requiring file I/O
- Size limits: 5MB enforcement per file
- Visual indicators: Emoji-based file type icons
- Comprehensive tests: 10+ test cases covering edge cases
- Backward compatibility: Fully compatible with existing attachment system
All automated verification checks passed with no confirmed bugs in the changed code. The state machine approach for path parsing correctly handles complex edge cases like spaces in filenames, quoted paths, and escape sequences.
✅ Ready for merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-By: cagent