فهرست منبع

fix(googlereader): reject disable-tag requests without a stream

Without an s parameter, disable-tag removed no category and returned
200. Return 400 instead.
Fred 8 ساعت پیش
والد
کامیت
3650351780
2فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  1. 4 0
      internal/googlereader/handler.go
  2. 1 0
      internal/googlereader/tag_integration_test.go

+ 4 - 0
internal/googlereader/handler.go

@@ -770,6 +770,10 @@ func (h *greaderHandler) disableTagHandler(w http.ResponseWriter, r *http.Reques
 		response.JSONBadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramStreamID))
 		response.JSONBadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramStreamID))
 		return
 		return
 	}
 	}
+	if len(streams) == 0 {
+		response.JSONBadRequest(w, r, fmt.Errorf("googlereader: missing %s parameter", paramStreamID))
+		return
+	}
 
 
 	titles := make([]string, len(streams))
 	titles := make([]string, len(streams))
 	for i, stream := range streams {
 	for i, stream := range streams {

+ 1 - 0
internal/googlereader/tag_integration_test.go

@@ -143,6 +143,7 @@ func TestDisableTagRejectsInvalidRequests(t *testing.T) {
 		streams        []string
 		streams        []string
 		expectedStatus int
 		expectedStatus int
 	}{
 	}{
+		{"missing stream", nil, http.StatusBadRequest},
 		{"invalid stream", []string{"invalid"}, http.StatusBadRequest},
 		{"invalid stream", []string{"invalid"}, http.StatusBadRequest},
 		{"not a label", []string{feedStream(1)}, http.StatusBadRequest},
 		{"not a label", []string{feedStream(1)}, http.StatusBadRequest},
 		{"a label and a state", []string{labelStream("All"), starredStream}, http.StatusBadRequest},
 		{"a label and a state", []string{labelStream("All"), starredStream}, http.StatusBadRequest},