Skip to content

Commit 0dc9b41

Browse files
authored
Merge pull request #2 from fsbraun/fix/escape
Fix/escape
2 parents 83e99f0 + db4748a commit 0dc9b41

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.github/workflows/publish-to-test-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
environment:
1313
name: pypi
14-
url: https://pypi.org/p/djangocms-frontend
14+
url: https://test.pypi.org/p/djangocms-frontend
1515
permissions:
1616
id-token: write
1717
steps:

README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ For a manual install:
132132
133133
- run ``python manage.py migrate``
134134

135-
If you use **Django < 3.2** please also add ``django-jsonfield-backport`` to
136-
your ``requirements.txt`` and ``django_jsonfield_backport`` to your
137-
``INSTALLED_APPS`` list.
138-
139135
**djangocms-frontend** has a weak dependencies on **djangocms-icon** you can
140136
install separately or by adding an option:
141137

@@ -169,7 +165,7 @@ See `LICENSE <https://github.com/django-cms/djangocms-frontend/blob/master/LICEN
169165
.. |python| image:: https://img.shields.io/badge/python-3.7+-blue.svg
170166
:target: https://pypi.org/project/djangocms-frontend/
171167

172-
.. |django| image:: https://img.shields.io/badge/django-3.2--4.2-blue.svg
168+
.. |django| image:: https://img.shields.io/badge/django-3.2---blue.svg
173169
:target: https://www.djangoproject.com/
174170

175171
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.8%2B-blue.svg

djangocms_frontend/contrib/link/helpers.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.contrib.contenttypes.models import ContentType
88
from django.core.exceptions import FieldError, ObjectDoesNotExist
99
from django.utils.encoding import force_str
10-
from django.utils.html import mark_safe
1110

1211
from djangocms_frontend.settings import EMPTY_CHOICE
1312

@@ -62,6 +61,15 @@ def get_object_for_value(value):
6261
return None
6362

6463

64+
def unescape(text, nbsp):
65+
return (text.replace("&nbsp;", nbsp)
66+
.replace("&amp;", "&")
67+
.replace("&lt;", "<")
68+
.replace("&gt;", ">")
69+
.replace("&quot;", '"')
70+
.replace("&#x27;", "'"))
71+
72+
6573
def get_link_choices(request, term="", lang=None, nbsp=None):
6674
global _querysets
6775

@@ -78,7 +86,9 @@ def get_link_choices(request, term="", lang=None, nbsp=None):
7886
"children": [
7987
dict(
8088
id=f"{type_id}-{page}",
81-
text=mark_safe(name.replace("&nbsp;", nbsp)),
89+
# django admin's autocomplete view requires unescaped strings
90+
# get_page_choices escepes strings, so we undo the escape
91+
text=unescape(name, nbsp),
8292
)
8393
for page, name in descr
8494
if not isinstance(term, str) or term.upper() in name.upper()

0 commit comments

Comments
 (0)