v0.6.3 - #25
Merged
Merged
Conversation
saveTextAsFile now returns error instead of void. Caller maps: - path traversal -> 400 Bad Request - save failure -> 500 Internal Server Error - success -> 200 OK (explicit, not implicit) Tests added for all three branches.
New methods on ReceiveService: - ClaimFile: validates session/senderIP/fileId/token under mutex, marks as uploading - CompleteFile: removes file from session after success - FailFile: resets file state to pending on failure - GetSessionProgress: safe RLock read of progress bar pointer UploadHandlerV2 now uses ClaimFile/CompleteFile/FailFile instead of GetSessionByID + RemoveFileFromSession, preventing duplicate concurrent uploads of the same token. Tests: concurrent claim (one success, one ErrAlreadyUploading), error cases (invalid session/file/token/IP), CompleteFile lifecycle
Refactored stripping to write to a separate destination path: - StripTo(src, dest) writes stripped image to dest, never touches src - Strip(path) uses temp-in-dir + rename for atomic in-place replacement - stripJPEGTo/stripPNGTo: fail closed when SOS/IEND not found - PNG: strip eXIf chunk in addition to tEXt/zTXt/iTXt - Magic sniff (checks first 8 bytes), not just file extension - writeAtomic helper for safe temp+rename writes SendFile private mode: strips to temp file, uploads temp, defers cleanup. Original file bytes are never modified. Tests: JPEG EXIF removal, original unchanged, truncated JPEG error, PNG eXIf stripping, non-image passthrough, nonexistent file error
sanitizeName strips ASCII control bytes 0x00-0x1F from FileName in PrepareUploadHandlerV2 after decoding the request, preventing UI spoofing and terminal escape injection via display prompts. Test: control-char filename in prepare-upload returns 200 (sanitized)
Guard against f.Size < 0 in PrepareUploadHandlerV2's disk-space loop. Without this check, a negative size reduces totalSize and bypasses the free-space guard, and the value flows into uint64 conversion which wraps to a large positive number. Test: prepare-upload with Size: -10 returns 400 Bad Request
Release sessionMutex before calling Progress.Wait() to match the pattern used by cleanupLoop and CloseAllSessions. This prevents stalling other operations (like concurrent ClaimFile calls) during the progress bar Wait, which can block on terminal rendering.
Private mode previously created empty temp files for non-image files (PDFs, zips, text files) because StripTo returns nil for non-images (no error, no output). The empty temp then replaced the real file in the upload map, causing 0-byte uploads. Fix: export IsImageFile from metadata package; guard the strip loop so non-images keep their original path unchanged.
After sanitizing control chars from filenames, reject names that become empty with 400 Bad Request (prevents downstream confusion). Strengthened TestPrepareUpload_SanitizesControlChars to assert the stored session filename is 'bad.txt' after sanitization (not just that prepare returns 200).
…pty not error - Use CombinedOutput() instead of Output() to capture stderr - Include tool name in both Read() and Write() error messages - Treat tool exit with no output as empty clipboard (xclip/wl-paste exit 1 when clipboard is empty) instead of returning a cryptic error - Expand 'no tool found' message with actionable install hints
Remove the temp file creation for --clipboard and --stdin flags, and instead thread raw byte content through the send pipeline via a new SendOption/WithInMemoryFile mechanism. Changes: - pkg/send/send.go: Add SendOption, WithInMemoryFile, sendConfig, memFile types. SendToDevice and SendFiles now accept variadic SendOption. Process in-memory files alongside file-based files in the fileDto build loop and upload goroutines. - pkg/send/upload.go: Add memReadSeekCloser (bytes.Reader wrapper with no-op Close), fileReader interface. Extract uploadStream() from uploadFile() so both file and in-memory uploads share the same stream logic. - cmd/localgo/cmd/send.go: Replace os.CreateTemp/defer os.Remove with send.WithInMemoryFile() calls. Remove the localgo-clip- prefix hack entirely. Adjust file picker/empty checks to account for sendOpts.
Evaluate session.SessionID and file token before goroutines to avoid concurrent map access without the session mutex.
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.
v0.6.3
Features
Fixes
Protocol