Skip to content

Commit

Permalink
Merge pull request #592 from EsupPortail/dev
Browse files Browse the repository at this point in the history
remove control characters in video title which are not supported in X…
  • Loading branch information
ptitloup committed Feb 21, 2022
2 parents fef269c + d55a4e4 commit f8d0d17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pod/video/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def items(self, obj):
return obj.order_by("-date_added")[:30]

def item_title(self, item):
return "%s | %s" % (item.owner, item.title)
sub = re.sub(r"[\x00-\x08\x0B-\x0C\x0E-\x1F]", "", item.title)
return "%s | %s" % (item.owner.get_full_name(), sub)

def item_link(self, item):
return "".join([self.author_link, item.get_absolute_url()])
Expand Down
5 changes: 4 additions & 1 deletion pod/video/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Esup-Pod Video models."""

import os
import re
import time
import unicodedata
import json
Expand Down Expand Up @@ -881,6 +882,8 @@ def get_thumbnail_url(self):
@property
def get_thumbnail_admin(self):
thumbnail_url = ""
# fix title for xml description
title = re.sub(r"[\x00-\x08\x0B-\x0C\x0E-\x1F]", "", self.title)
if self.thumbnail and self.thumbnail.file_exist():
im = get_thumbnail(self.thumbnail.file, "100x100", crop="center", quality=72)
thumbnail_url = im.url
Expand All @@ -893,7 +896,7 @@ def get_thumbnail_admin(self):
'src="%s" alt="%s" loading="lazy"/>'
% (
thumbnail_url,
self.title.replace("{", "").replace("}", "").replace('"', "'"),
title.replace("{", "").replace("}", "").replace('"', "'"),
)
)

Expand Down

0 comments on commit f8d0d17

Please sign in to comment.