mirror of
https://github.com/minio/minio.git
synced 2026-02-04 18:00:15 -05:00
storage: Use request.Form and avoid mux matching (#13858)
request.Form uses less memory allocation and avoids gorilla mux matching with weird characters in parameters such as '\n' - Remove Queries() to avoid matching - Ensure r.ParseForm is called to populate fields - Add a unit test for object names with '\n'
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -312,18 +313,24 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
volumeName string
|
||||
objectName string
|
||||
data []byte
|
||||
expectErr bool
|
||||
volumeName string
|
||||
objectName string
|
||||
data []byte
|
||||
expectErr bool
|
||||
ignoreIfWindows bool
|
||||
}{
|
||||
{"foo", "myobject", []byte("foo"), false},
|
||||
{"foo", "myobject", []byte{}, false},
|
||||
{"foo", "myobject", []byte("foo"), false, false},
|
||||
{"foo", "myobject", []byte{}, false, false},
|
||||
// volume not found error.
|
||||
{"bar", "myobject", []byte{}, true},
|
||||
{"bar", "myobject", []byte{}, true, false},
|
||||
// Weird '\n' in object name
|
||||
{"foo", "newline\n", []byte{}, false, true},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
if testCase.ignoreIfWindows && runtime.GOOS == "windows" {
|
||||
continue
|
||||
}
|
||||
err := storage.AppendFile(context.Background(), testCase.volumeName, testCase.objectName, testCase.data)
|
||||
expectErr := (err != nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user