Skip to content

Commit 5286cc0

Browse files
committed
Use limited JSON reader for text uploads
The limited non-JSON reader is intended for file uploads, where each request contains chunked file data. Text uploads encrypt the text and include it in a JSON request, so the JSON reader should be used instead. Fixes #3
1 parent 0bb5431 commit 5286cc0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

backend/server/transfer/send/handlers.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ func UploadDataHandler(w http.ResponseWriter, req *http.Request, userID string)
130130
// UploadPlaintextHandler handles uploading plaintext with a max size of
131131
// shared.MaxPlaintextLen characters (constants.go).
132132
func UploadPlaintextHandler(w http.ResponseWriter, req *http.Request) {
133-
data, err := utils.LimitedReader(w, req.Body)
134133
var plaintextUpload shared.PlaintextUpload
135-
err = json.Unmarshal(data, &plaintextUpload)
134+
err := utils.LimitedJSONReader(w, req.Body).Decode(&plaintextUpload)
136135
if err != nil {
137136
log.Printf("Error: %v\n", err)
138137
http.Error(w, "Invalid request body", http.StatusBadRequest)

0 commit comments

Comments
 (0)