Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Update bleach to latest version

Roland Geiderdf61aa005333
diff --git a/requirements.txt b/requirements.txt
index c6dec29aa..ed74db3aa 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@
#
# Application
-bleach~=4.1
+bleach[css]~=5.0
django-bootstrap-breadcrumbs~=0.9
django-formtools~=2.3
django-recaptcha~=3.0.0
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.py
index 1e99dadda..074cf4f7c 100644
--- a/wger/exercises/api/views.py
+++ b/wger/exercises/api/views.py
@@ -27,6 +27,7 @@ from django.views.decorators.cache import cache_page
# Third Party
import bleach
+from bleach.css_sanitizer import CSSSanitizer
from actstream import action as actstream_action
from easy_thumbnails.alias import aliases
from easy_thumbnails.files import get_thumbnailer
@@ -145,7 +146,7 @@ class ExerciseTranslationViewSet(ModelViewSet):
serializer.validated_data['description'],
tags=HTML_TAG_WHITELIST,
attributes=HTML_ATTRIBUTES_WHITELIST,
- styles=HTML_STYLES_WHITELIST,
+ css_sanitizer=CSSSanitizer(allowed_css_properties=HTML_STYLES_WHITELIST),
strip=True
)
super().perform_create(serializer)
@@ -174,7 +175,7 @@ class ExerciseTranslationViewSet(ModelViewSet):
serializer.validated_data['description'],
tags=HTML_TAG_WHITELIST,
attributes=HTML_ATTRIBUTES_WHITELIST,
- styles=HTML_STYLES_WHITELIST,
+ css_sanitizer=CSSSanitizer(allowed_css_properties=HTML_STYLES_WHITELIST),
strip=True
)
diff --git a/wger/utils/generic_views.py b/wger/utils/generic_views.py
index 7585002b2..d05d663f6 100644
--- a/wger/utils/generic_views.py
+++ b/wger/utils/generic_views.py
@@ -32,6 +32,7 @@ from django.views.generic.edit import ModelFormMixin
# Third Party
import bleach
+from bleach.css_sanitizer import CSSSanitizer
from crispy_forms.helper import FormHelper
from crispy_forms.layout import (
ButtonHolder,
@@ -242,7 +243,7 @@ class WgerFormMixin(ModelFormMixin):
getattr(form.instance, field),
tags=HTML_TAG_WHITELIST,
attributes=HTML_ATTRIBUTES_WHITELIST,
- styles=HTML_STYLES_WHITELIST,
+ css_sanitizer=CSSSanitizer(allowed_css_properties=HTML_STYLES_WHITELIST),
strip=True
)
)