validateImportBody validates incoming import bodies
(body Body)
| 51 | |
| 52 | // validateImportBody validates incoming import bodies |
| 53 | func validateImportBody(body Body) error { |
| 54 | if isPurged, ok := body[BodyPurged].(bool); ok && isPurged { |
| 55 | return base.ErrImportCancelledPurged |
| 56 | } |
| 57 | |
| 58 | // Prevent disallowed internal properties from being used |
| 59 | disallowed := []string{BodyId, BodyRev, BodyExpiry, BodyRevisions} |
| 60 | for _, prop := range disallowed { |
| 61 | if _, ok := body[prop]; ok { |
| 62 | return base.NewHTTPError(http.StatusNotFound, "top-level property '"+prop+"' is a reserved internal property therefore cannot be imported") |
| 63 | } |
| 64 | } |
| 65 | // TODO: Validate attachment data to ensure user is not setting invalid attachments |
| 66 | |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | // validateBlipBody validates incoming blip rev bodies |
| 71 | // Takes a rawBody to avoid an unnecessary call to doc.BodyBytes() |
no test coverage detected