Skip to content

Commit 421c86b

Browse files
authored
fix: View expanded svg images from <img> tags to avoid js attacks (#1429)
* Fix #1377 * feat: expand images in `<img>` tag to avoid javascript attacks * Embed in img tags svg only * Remove canonical url display from directory listing for svg * Add test * Remove unused Media class * Change function of canonical url button * Remove superflous `} ` * Update NL locale
1 parent 964f48d commit 421c86b

File tree

48 files changed

+1393
-1158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1393
-1158
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
CHANGELOG
33
=========
44

5-
unreleased
6-
==========
5+
3.1.0 (2023-10-01)
6+
==================
77

88
* feat: limit uploaded image area (width x height) to prevent decompression
99
bombs
10+
* feat: Canonical URL action button now copies canonical URL to the user's
11+
clipboard
1012
* fix: Run validators on updated files in file change view
1113
* fix: Update mime type if uploading file in file change view
1214
* fix: Do not allow to remove the file field from an uplaoded file in

filer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
8. Publish the release and it will automatically release to pypi
1414
"""
1515

16-
__version__ = '3.0.6'
16+
__version__ = '3.1.0'

filer/admin/imageadmin.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from django import forms
2+
from django.shortcuts import get_object_or_404, render
3+
from django.urls import path
24
from django.utils.translation import gettext as _
35
from django.utils.translation import gettext_lazy
46

@@ -80,19 +82,24 @@ class Meta:
8082
model = Image
8183
exclude = ()
8284

83-
class Media:
84-
css = {
85-
# 'all': (settings.MEDIA_URL + 'filer/css/focal_point.css',)
86-
}
87-
js = (
88-
89-
)
90-
9185

9286
class ImageAdmin(FileAdmin):
9387
change_form_template = 'admin/filer/image/change_form.html'
9488
form = ImageAdminForm
9589

90+
def get_urls(self):
91+
return super().get_urls() + [
92+
path("expand/<int:file_id>",
93+
self.admin_site.admin_view(self.expand_view),
94+
name=f"filer_{self.model._meta.model_name}_expand_view")
95+
]
96+
97+
def expand_view(self, request, file_id):
98+
image = get_object_or_404(self.model, pk=file_id)
99+
return render(request, "admin/filer/image/expand.html", context={
100+
"original_url": image.url
101+
})
102+
96103

97104
if FILER_IMAGE_MODEL == 'filer.Image':
98105
extra_main_fields = ('author', 'default_alt_text', 'default_caption',)
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)