Skip to content

Commit

Permalink
Add check to upload CSV file's content-type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Faakhir30 committed Oct 1, 2024
1 parent 3361b58 commit a6ca22f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plone/restapi/services/aliases/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ def _reply_csv(self):
form = self.request.form
if not form.get("file"):
raise BadRequest("No file uploaded")

file = form["file"]

if file.headers.get("Content-Type") not in ("text/csv", "application/csv"):
raise BadRequest("Uploaded file is not a valid CSV file")

controlpanel = RedirectsControlPanel(self.context, self.request)
storage = getUtility(IRedirectionStorage)
status = IStatusMessage(self.request)
portal = getSite()
file = form["file"]
controlpanel.upload(file, portal, storage, status)
file.close()

Expand Down

0 comments on commit a6ca22f

Please sign in to comment.