Integrate graphics, RAW, audio and CAD Craft tools with protected saves
This commit is contained in:
1 parent
6e36b6c4b7
commit
852140c3a7
24 files changed
+600
-74
No files matched your search
+7
-1
@@ -62,7 +62,7 @@ func craftDocumentHandler(manager *addons.Manager, cache FileCache) handleFunc {
|
||||
return http.StatusBadRequest, nil
|
||||
}
|
||||
extension := strings.ToLower(path.Ext(requested))
|
||||
if extension != tool.Extension && !(id != "pdfcraft" && r.Method == "PUT" && extension == ".pdf") {
|
||||
if (r.Method == "PUT" && !tool.CanSave(extension)) || (r.Method != "PUT" && !tool.CanOpen(extension)) {
|
||||
return http.StatusUnsupportedMediaType, nil
|
||||
}
|
||||
if !d.Check(requested) {
|
||||
@@ -91,6 +91,9 @@ func craftDocumentHandler(manager *addons.Manager, cache FileCache) handleFunc {
|
||||
_, err = w.Write(data)
|
||||
return 0, err
|
||||
}
|
||||
if r.Method == "POST" && id != "wordcraft" && id != "gridcraft" && id != "deckcraft" && id != "pdfcraft" {
|
||||
return http.StatusMethodNotAllowed, nil
|
||||
}
|
||||
var body io.Reader = r.Body
|
||||
if r.Method == "POST" {
|
||||
if !d.user.Perm.Create {
|
||||
@@ -191,6 +194,9 @@ func validateCraftDocument(extension string, data []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if supported, err := validateCreativeDocument(extension, data); supported {
|
||||
return err
|
||||
}
|
||||
mainPart, ok := map[string]string{".xlsx": "xl/workbook.xml", ".docx": "word/document.xml", ".pptx": "ppt/presentation.xml"}[extension]
|
||||
if !ok {
|
||||
return errors.New("unsupported document format")
|
||||
|
||||
Reference in new issue
Block a user