From af8bb569db3d65f5cd57132f499b2a417783d1e3 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Wed, 22 Nov 2023 16:05:25 +0100 Subject: [PATCH] alternative attempt: unescape all entities --- plone/app/content/browser/vocabulary.py | 7 +++++-- plone/app/content/tests/test_widgets.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plone/app/content/browser/vocabulary.py b/plone/app/content/browser/vocabulary.py index 75d5aad..7878407 100644 --- a/plone/app/content/browser/vocabulary.py +++ b/plone/app/content/browser/vocabulary.py @@ -1,5 +1,6 @@ from AccessControl import getSecurityManager from Acquisition import aq_base +from html import unescape from logging import getLogger from plone.app.content.utils import json_dumps from plone.app.content.utils import json_loads @@ -260,8 +261,10 @@ def __call__(self): else: items = [ { - "id": transform.scrub_html(item.value).replace("&", "&"), - "text": transform.scrub_html(item.title).replace("&", "&") if item.title else "", + "id": unescape(transform.scrub_html(item.value)), + "text": unescape(transform.scrub_html(item.title)) + if item.title + else "", } for item in results ] diff --git a/plone/app/content/tests/test_widgets.py b/plone/app/content/tests/test_widgets.py index df6b818..95e662d 100644 --- a/plone/app/content/tests/test_widgets.py +++ b/plone/app/content/tests/test_widgets.py @@ -270,7 +270,7 @@ def testVocabularyEncoding(self): self.assertEqual(result["id"], test_val) def testVocabularyHtmlEntity(self): - """ The vocabulary token should not convert to htmlentities. + """The vocabulary token should not convert to htmlentities. See https://github.com/plone/Products.CMFPlone/issues/3874 """ test_val = "Question & Answer"