Fixes #22480: Revert forced handling of image attachments as downloads (#22493)

This commit is contained in:
Jeremy Stretch 2026-06-18 17:09:04 -04:00 committed by GitHub
parent d217acdc85
commit e92367b3f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -124,8 +124,8 @@ class MediaViewTestCase(TestCase):
with patch('netbox.views.misc.serve', return_value=HttpResponse(status=200)):
response = self.client.get(url)
self.assertHttpStatus(response, 200)
self.assertEqual(response['Content-Disposition'], 'attachment')
self.assertEqual(response['X-Content-Type-Options'], 'nosniff')
self.assertEqual(response['Content-Security-Policy'], "sandbox; default-src 'none'")
self.assertEqual(response['X-Content-Type-Options'], "nosniff")
def test_image_attachment_without_permission(self):
url = reverse('media', kwargs={'path': self.image_attachment.image.name})
@ -145,8 +145,8 @@ class MediaViewTestCase(TestCase):
with patch('netbox.views.misc.serve', return_value=HttpResponse(status=200)):
response = self.client.get(url)
self.assertHttpStatus(response, 200)
self.assertEqual(response['Content-Disposition'], 'attachment')
self.assertEqual(response['X-Content-Type-Options'], 'nosniff')
self.assertEqual(response['Content-Security-Policy'], "sandbox; default-src 'none'")
self.assertEqual(response['X-Content-Type-Options'], "nosniff")
def test_device_type_without_permission(self):
url = reverse('media', kwargs={'path': self.device_type.front_image.name})

View File

@ -159,6 +159,6 @@ class MediaView(TokenConditionalLoginRequiredMixin, View):
raise Http404
response = serve(request, path, document_root=settings.MEDIA_ROOT)
response['Content-Disposition'] = 'attachment'
response['X-Content-Type-Options'] = 'nosniff'
response['Content-Security-Policy'] = "sandbox; default-src 'none'"
response['X-Content-Type-Options'] = "nosniff"
return response