mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
CSP: Exclude PDF editor (just doesn't work in FF)
This commit is contained in:
@@ -220,7 +220,14 @@ class SecurityMiddleware(MiddlewareMixin):
|
||||
domain = '%s:%d' % (domain, siteurlsplit.port)
|
||||
dynamicdomain += " " + domain
|
||||
|
||||
if request.path not in self.CSP_EXEMPT:
|
||||
if request.path not in self.CSP_EXEMPT and not getattr(resp, '_csp_ignore', False):
|
||||
resp['Content-Security-Policy'] = _render_csp(h).format(static=staticdomain, dynamic=dynamicdomain,
|
||||
media=mediadomain, nonce=request.csp_nonce)
|
||||
for k, v in h.items():
|
||||
h[k] = ' '.join(v).format(static=staticdomain, dynamic=dynamicdomain, media=mediadomain,
|
||||
nonce=request.csp_nonce).split(' ')
|
||||
resp['Content-Security-Policy'] = _render_csp(h)
|
||||
elif 'Content-Security-Policy' in resp:
|
||||
del resp['Content-Security-Policy']
|
||||
|
||||
return resp
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from django.http import (
|
||||
HttpResponseBadRequest, HttpResponse)
|
||||
from django.http import HttpResponse, HttpResponseBadRequest
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
logger = logging.getLogger('pretix.security.csp')
|
||||
|
||||
@@ -44,7 +44,7 @@ class EditorView(EventPermissionRequiredMixin, TemplateView):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
resp = super().get(request, *args, **kwargs)
|
||||
resp['Content-Security-Policy'] = "script-src 'unsafe-eval'; style-src 'unsafe-inline'; img-src blob:; font-src data: blob:"
|
||||
resp._csp_ignore = True
|
||||
return resp
|
||||
|
||||
def process_upload(self):
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.views.generic import RedirectView
|
||||
import pretix.control.urls
|
||||
import pretix.presale.urls
|
||||
|
||||
from .base.views import cachedfiles, health, js_catalog, metrics, redirect, csp
|
||||
from .base.views import cachedfiles, csp, health, js_catalog, metrics, redirect
|
||||
|
||||
base_patterns = [
|
||||
url(r'^download/(?P<id>[^/]+)/$', cachedfiles.DownloadView.as_view(),
|
||||
|
||||
Reference in New Issue
Block a user