Add file upload functionality to the agent. Implement API endpoint for uploading files, including validation and error handling. Update web interface to support file selection and display upload status. Enhance input handling with configurable key delay for text input.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package files
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSafeUploadName(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := map[string]bool{
|
||||
"notes.txt": true,
|
||||
"../evil.exe": true, // basename keeps evil.exe
|
||||
"..": false,
|
||||
".": false,
|
||||
"": false,
|
||||
`C:\temp\foo.txt`: true,
|
||||
}
|
||||
for name, wantOK := range cases {
|
||||
got, err := SafeUploadName(name)
|
||||
if wantOK {
|
||||
if err != nil {
|
||||
t.Fatalf("SafeUploadName(%q) err = %v", name, err)
|
||||
}
|
||||
if got == "" || got == "." || got == ".." {
|
||||
t.Fatalf("SafeUploadName(%q) = %q", name, got)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("SafeUploadName(%q) = %q, want error", name, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user