Skip to content

Commit

Permalink
🐛 [#4795] Validate .msg file type only on backend
Browse files Browse the repository at this point in the history
The sdk cannot determine which content type belongs to a .msg file. This is because (at least) Linux and MacOS don't know this file type.

To make sure these files can be uploaded, the type property on the FileSerializer is now optional. For .smg files a new rule has been added to the MimeTypeValidator
  • Loading branch information
robinmolen committed Dec 19, 2024
1 parent 26063d9 commit afdda94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/openforms/formio/api/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def __call__(self, value: UploadedFile) -> None:
"image/heif",
):
return
# 4795
# The sdk cannot determine the file type of .msg files, which result into
# content_type "". So we have to validate these for ourselves
elif mime_type == "application/vnd.ms-outlook" and ext == "msg":
return

# gh #4658
# Windows use application/x-zip-compressed as a mimetype for .zip files, which
Expand Down
9 changes: 1 addition & 8 deletions src/openforms/formio/components/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,7 @@ class FileSerializer(serializers.Serializer):
originalName = serializers.CharField(trim_whitespace=False)
size = serializers.IntegerField(min_value=0)
storage = serializers.ChoiceField(choices=["url"])
type = serializers.CharField(
error_messages={
"blank": _(
"Could not determine the file type. Please make sure the file name "
"has an extension."
),
}
)
type = serializers.CharField(required=False, allow_blank=True)
url = serializers.URLField()
data = FileDataSerializer() # type: ignore

Expand Down

0 comments on commit afdda94

Please sign in to comment.