-
Notifications
You must be signed in to change notification settings - Fork 2
Rework mime type white list #2198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8699bc1
66ac404
5ebe0fb
9416abf
7eed62a
4ab42df
cf252e2
6e9afd6
3f718d2
5572020
a6bd385
1293c8e
af685f5
a50f6f0
458a82d
8d99429
c31d0e3
eee980c
248819a
5621994
21274d1
c4a1eef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
| from onegov.file.utils import IMAGE_MIME_TYPES_AND_SVG | ||
| from onegov.form import log, _ | ||
| from onegov.form.utils import path_to_filename | ||
| from onegov.form.validators import ValidPhoneNumber | ||
| from onegov.form.validators import ValidPhoneNumber, WhitelistedMimeType | ||
| from onegov.form.widgets import ChosenSelectWidget | ||
| from onegov.form.widgets import LinkPanelWidget | ||
| from onegov.form.widgets import DurationInput | ||
|
|
@@ -260,6 +260,7 @@ class UploadField(FileField): | |
| action: Literal['keep', 'replace', 'delete'] | ||
| file: IO[bytes] | None | ||
| filename: str | None | ||
| validators = [WhitelistedMimeType()] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not very robust, we definitely should overwrite I kind of like the extra parameter better, since it means we don't need to import You can then pass it on to |
||
|
|
||
| if TYPE_CHECKING: | ||
| def __init__( | ||
|
|
@@ -448,6 +449,7 @@ def _add_entry(self, d: _MultiDictLikeWithGetlist, /) -> UploadField: | |
|
|
||
| upload_field_class: type[UploadField] = UploadField | ||
| upload_widget: Widget[UploadField] = UploadWidget() | ||
| validators = [WhitelistedMimeType()] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here |
||
|
|
||
| def __init__( | ||
| self, | ||
|
|
@@ -479,11 +481,11 @@ def __init__( | |
|
|
||
| # a lot of the arguments we just pass through to the subfield | ||
| unbound_field = self.upload_field_class( | ||
| validators=validators, # type:ignore[arg-type] | ||
| filters=filters, | ||
| description=description, | ||
| widget=upload_widget, | ||
| render_kw=render_kw, | ||
| validators=validators, # type:ignore[arg-type] | ||
| **extra_arguments | ||
| ) | ||
| super().__init__( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the resulting list for
get_supported_image_mime_typesis: