Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix code formatting
akjanik2ec2724a03c3
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex ca13df61ff..d2018adddb 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -1,4 +1,5 @@-from bleach.sanitizer import ALLOWED_TAGS+import bleach+from bleach.sanitizer import ALLOWED_TAGS as BLEACH_ALLOWED_TAGSfrom django import formsfrom django.db.models import Countfrom django.forms.models import ModelChoiceIterator@@ -6,7 +7,6 @@ from django.forms.widgets import CheckboxSelectMultiplefrom django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazy-import bleachfrom . import ProductBulkActionfrom ...product.models import (@@ -17,16 +17,14 @@ from .widgets import ImagePreviewWidgetclass RichTextField(forms.CharField):- """- A field for rich text editor, providing backend sanitization- """+ """A field for rich text editor, providing backend sanitization."""widget = RichTextEditorWidget- ALLOWED_TAGS.extend([u'br', u'p', u'h2', u'h3'])+ ALLOWED_TAGS = BLEACH_ALLOWED_TAGS + ['br', 'p', 'h2', 'h3']def to_python(self, value):value = super().to_python(value)- value = bleach.clean(value, tags=ALLOWED_TAGS)+ value = bleach.clean(value, tags=self.ALLOWED_TAGS)return valuediff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 45b050c3b5..2530f3ad66 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -686,17 +686,19 @@ def test_sanitize_product_description(product_type, default_category):name='Test Product', price=10, description='', pk=10,product_type=product_type, category=default_category)data = model_to_dict(product)- data['description'] = '<b>bold</b><p><i>italic</i></p><h2>Header</h2>' \- '<h3>subheader</h3><blockquote>quote</blockquote>' \- '<p><a href="www.mirumee.com">link</a></p>' \- '<p>an <script>evil()</script> example</p>'+ data['description'] = (+ '<b>bold</b><p><i>italic</i></p><h2>Header</h2>'+ '<h3>subheader</h3><blockquote>quote</blockquote>'+ '<p><a href="www.mirumee.com">link</a></p>'+ '<p>an <script>evil()</script>example</p>')data['price'] = 20form = ProductForm(data, instance=product)assert form.is_valid()form.save()- assert product.description == '<b>bold</b><p><i>italic</i></p>' \- '<h2>Header</h2><h3>subheader</h3>' \- '<blockquote>quote</blockquote>' \- '<p><a href="www.mirumee.com">link</a></p>' \- '<p>an <script>evil()</script>' \- ' example</p>'+ assert product.description == (+ '<b>bold</b><p><i>italic</i></p>'+ '<h2>Header</h2><h3>subheader</h3>'+ '<blockquote>quote</blockquote>'+ '<p><a href="www.mirumee.com">link</a></p>'+ '<p>an <script>evil()</script>'+ 'example</p>')