Fix editor lint findings
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
944629e7af3564a80c5ada389697884efdd2787c- Parents
-
5ac31a3 - Tree
9ba9341
944629e
944629e7af3564a80c5ada389697884efdd2787c5ac31a3
9ba9341| Status | File | + | - |
|---|---|---|---|
| M |
internal/repos/webedit/webedit.go
|
1 | 3 |
| M |
internal/web/handlers/repo/editor.go
|
4 | 0 |
internal/repos/webedit/webedit.gomodified@@ -534,9 +534,7 @@ func enqueuePushProcess(ctx context.Context, pool *pgxpool.Pool, repoID, actorUs | |||
| 534 | }{PushEventID: event.ID}, worker.EnqueueOptions{}); err != nil { | 534 | }{PushEventID: event.ID}, worker.EnqueueOptions{}); err != nil { |
| 535 | return 0, err | 535 | return 0, err |
| 536 | } | 536 | } |
| 537 | - if err := worker.Notify(ctx, tx); err != nil { | 537 | + _ = worker.Notify(ctx, tx) // Workers also poll; keep the commit path live if NOTIFY fails. |
| 538 | - // Workers also poll. Keep the commit path live if NOTIFY fails. | ||
| 539 | - } | ||
| 540 | if err := tx.Commit(ctx); err != nil { | 538 | if err := tx.Commit(ctx); err != nil { |
| 541 | return 0, fmt.Errorf("webedit: commit push event tx: %w", err) | 539 | return 0, fmt.Errorf("webedit: commit push event tx: %w", err) |
| 542 | } | 540 | } |
internal/web/handlers/repo/editor.gomodified@@ -214,6 +214,10 @@ func (h *Handlers) codeUploadSubmit(w http.ResponseWriter, r *http.Request) { | |||
| 214 | return | 214 | return |
| 215 | } | 215 | } |
| 216 | r.Body = http.MaxBytesReader(w, r.Body, webedit.MaxUploadBytes) | 216 | r.Body = http.MaxBytesReader(w, r.Body, webedit.MaxUploadBytes) |
| 217 | + // MaxBytesReader above caps the full multipart request body before | ||
| 218 | + // ParseMultipartForm can spill parts to memory/disk. | ||
| 219 | + // | ||
| 220 | + //nolint:gosec // G120: request body is capped by MaxBytesReader. | ||
| 217 | if err := r.ParseMultipartForm(webedit.MaxUploadBytes); err != nil { | 221 | if err := r.ParseMultipartForm(webedit.MaxUploadBytes); err != nil { |
| 218 | data := h.editorData(r, cc, "upload", "", "") | 222 | data := h.editorData(r, cc, "upload", "", "") |
| 219 | data.Error = "The uploaded files are too large or could not be read." | 223 | data.Error = "The uploaded files are too large or could not be read." |