Skip to content

Commit

Permalink
Update edit identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozzie Isaacs committed Jul 29, 2023
1 parent cce538d commit df74fdb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cps/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def __repr__(self):
return "https://www.databazeknih.cz/knihy/{0}".format(self.val)
elif self.val.lower().startswith("javascript:"):
return quote(self.val)
elif self.val.lower().startswith("data:"):
link , __, __ = str.partition(self.val, ",")
return link
else:
return "{0}".format(self.val)

Expand Down
5 changes: 4 additions & 1 deletion cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
from uuid import uuid4
from markupsafe import escape # dependency of flask
from functools import wraps
import re

try:
from lxml.html.clean import clean_html
from lxml.html.clean import clean_html, Cleaner
except ImportError:
clean_html = None

Expand Down Expand Up @@ -599,6 +600,8 @@ def identifier_list(to_save, book):
val_key = id_val_prefix + type_key[len(id_type_prefix):]
if val_key not in to_save.keys():
continue
if to_save[val_key].startswith("data:"):
to_save[val_key], __, __ = str.partition(to_save[val_key], ",")
result.append(db.Identifiers(to_save[val_key], type_value, book.id))
return result

Expand Down
2 changes: 1 addition & 1 deletion cps/templates/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2 id="title">{{ entry.title }}</h2>
<p>
<span class="glyphicon glyphicon-link"></span>
{% for identifier in entry.identifiers %}
<a href="{{ identifier }}" target="_blank" class="btn btn-xs btn-success"
<a href="{{ identifier|escape }}" target="_blank" class="btn btn-xs btn-success"
role="button">{{ identifier.format_type() }}</a>
{% endfor %}
</p>
Expand Down

0 comments on commit df74fdb

Please sign in to comment.