sanitize headlines
This commit is contained in:
		@ -9,6 +9,7 @@ from django.utils.html import format_html
 | 
				
			|||||||
from django.utils.translation import ugettext_lazy as _
 | 
					from django.utils.translation import ugettext_lazy as _
 | 
				
			||||||
from django.utils.functional import cached_property
 | 
					from django.utils.functional import cached_property
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import bleach
 | 
				
			||||||
from ckeditor.fields import RichTextField
 | 
					from ckeditor.fields import RichTextField
 | 
				
			||||||
from filer.fields.image import FilerImageField
 | 
					from filer.fields.image import FilerImageField
 | 
				
			||||||
from model_utils.managers import InheritanceQuerySet
 | 
					from model_utils.managers import InheritanceQuerySet
 | 
				
			||||||
@ -129,7 +130,8 @@ class Page(models.Model):
 | 
				
			|||||||
    def headline(self):
 | 
					    def headline(self):
 | 
				
			||||||
        if not self.content:
 | 
					        if not self.content:
 | 
				
			||||||
            return ''
 | 
					            return ''
 | 
				
			||||||
        headline = headline_re.search(self.content)
 | 
					        content = bleach.clean(self.content)
 | 
				
			||||||
 | 
					        headline = headline_re.search(content)
 | 
				
			||||||
        return headline.groupdict()['headline'] if headline else ''
 | 
					        return headline.groupdict()['headline'] if headline else ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,7 @@
 | 
				
			|||||||
</section>
 | 
					</section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% if is_paginated %}
 | 
					{% if is_paginated %}
 | 
				
			||||||
<hr>
 | 
					<hr/>
 | 
				
			||||||
{% update_query request.GET.copy page=None as GET %}
 | 
					{% update_query request.GET.copy page=None as GET %}
 | 
				
			||||||
{% with GET.urlencode as GET %}
 | 
					{% with GET.urlencode as GET %}
 | 
				
			||||||
<nav class="pagination is-centered" role="pagination" aria-label="{% trans "pagination" %}">
 | 
					<nav class="pagination is-centered" role="pagination" aria-label="{% trans "pagination" %}">
 | 
				
			||||||
 | 
				
			|||||||
@ -51,9 +51,7 @@ Context variables:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        {% if has_headline|default_if_none:True %}
 | 
					        {% if has_headline|default_if_none:True %}
 | 
				
			||||||
        <div class="headline">
 | 
					        <div class="headline">
 | 
				
			||||||
        {% block headline %}
 | 
					        {% block headline %}{{ object.headline }}{% endblock %}
 | 
				
			||||||
        {{ object.headline|safe }}
 | 
					 | 
				
			||||||
        {% endblock %}
 | 
					 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        {% endif %}
 | 
					        {% endif %}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ tzlocal>=1.4
 | 
				
			|||||||
mutagen>=1.37
 | 
					mutagen>=1.37
 | 
				
			||||||
pyyaml>=3.12
 | 
					pyyaml>=3.12
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bleach>=3.1.0
 | 
				
			||||||
django_filter>=2.2.0
 | 
					django_filter>=2.2.0
 | 
				
			||||||
django-taggit>=1.1.0
 | 
					django-taggit>=1.1.0
 | 
				
			||||||
django-filer>=1.5.0
 | 
					django-filer>=1.5.0
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user