Skip to content

Commit

Permalink
[Fixes: GeoNode#7105] Remove HTML tags from visualization (GeoNode#7106)
Browse files Browse the repository at this point in the history
* [Fixes: GeoNode#7015] Remove HTML tags from visualization

* [Fixes: GeoNode#7015] strip_tags removed inside model function, increase test coverage and fix template

(cherry picked from commit 9ac0741)

# Conflicts:
#	geonode/base/models.py
#	geonode/base/tests.py
  • Loading branch information
mattiagiupponi authored and afabiani committed Mar 19, 2021
1 parent 7eb59da commit 5d90dfe
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 138 deletions.
13 changes: 9 additions & 4 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.staticfiles.templatetags import staticfiles
from django.core.files.storage import default_storage as storage

from django.utils.html import strip_tags
from mptt.models import MPTTModel, TreeForeignKey

from imagekit.models import ImageSpecField
Expand Down Expand Up @@ -883,14 +883,19 @@ def __init__(self, *args, **kwargs):
super(ResourceBase, self).__init__(*args, **kwargs)

def __str__(self):
return "{0}".format(self.title)
return str(self.title)

def _remove_html_tags(self, attribute_str):
_attribute_str = attribute_str
try:
pattern = re.compile('<.*?>')
return re.sub(pattern, '', attribute_str)
_attribute_str = html.unescape(
re.sub(pattern, '', attribute_str).replace('\n', ' ').replace('\r', '').strip())
except Exception:
return attribute_str
if attribute_str:
_attribute_str = html.unescape(
attribute_str.replace('\n', ' ').replace('\r', '').strip())
return strip_tags(_attribute_str)

@property
def raw_abstract(self):
Expand Down
Loading

0 comments on commit 5d90dfe

Please sign in to comment.