Fixes
This commit is contained in:
1 parent
04794aea54
commit
cfd31f398c
61 files changed
+2062
-254
No files matched your search
@@ -43,13 +43,20 @@ func (s *Service) SaveUpload(ctx context.Context, companyID, userID uuid.UUID, u
|
||||
if uploadDir == "" {
|
||||
return nil, ClientMsg("upload directory not configured")
|
||||
}
|
||||
kind = strings.ToLower(strings.TrimSpace(kind))
|
||||
safe := sanitizeFileName(originalName)
|
||||
lower := strings.ToLower(safe)
|
||||
if !strings.HasSuffix(lower, ".csv") {
|
||||
return nil, ClientMsg("only .csv uploads are allowed")
|
||||
isCSV := strings.HasSuffix(lower, ".csv") || strings.HasSuffix(lower, ".tsv")
|
||||
isXML := strings.HasSuffix(lower, ".xml") && kind == "feed"
|
||||
isJSON := strings.HasSuffix(lower, ".json")
|
||||
if !isCSV && !isXML && !isJSON {
|
||||
return nil, ClientMsg("only CSV, JSON or XML feed uploads are allowed")
|
||||
}
|
||||
if contentType != "" &&
|
||||
!strings.Contains(strings.ToLower(contentType), "csv") &&
|
||||
!strings.Contains(strings.ToLower(contentType), "json") &&
|
||||
!strings.Contains(strings.ToLower(contentType), "xml") &&
|
||||
!strings.Contains(strings.ToLower(contentType), "tab-separated") &&
|
||||
!strings.Contains(strings.ToLower(contentType), "text/plain") &&
|
||||
!strings.Contains(strings.ToLower(contentType), "octet-stream") {
|
||||
return nil, ClientMsg("invalid content type for CSV upload")
|
||||
|
||||
Reference in new issue
Block a user