Skip to content

Commit

Permalink
Try to fix & issue
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Nov 22, 2023
1 parent 7178987 commit 850b8a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plone/app/content/browser/vocabulary.py
Expand Up @@ -260,8 +260,8 @@ def __call__(self):
else:
items = [
{
"id": transform.scrub_html(item.value),
"text": transform.scrub_html(item.title) if item.title else "",
"id": transform.scrub_html(item.value).replace("&", "&"),
"text": transform.scrub_html(item.title).replace("&", "&") if item.title else "",
}
for item in results
]
Expand Down
19 changes: 19 additions & 0 deletions plone/app/content/tests/test_widgets.py
Expand Up @@ -269,6 +269,25 @@ def testVocabularyEncoding(self):
self.assertEqual(result["text"], test_val)
self.assertEqual(result["id"], test_val)

def testVocabularyHtmlEntity(self):
""" The vocabulary token should not convert to htmlentities.
See https://github.com/plone/Products.CMFPlone/issues/3874
"""
test_val = "Question & Answer"

self.portal.invokeFactory("Document", id="page", title="page")
self.portal.page.subject = (test_val,)
self.portal.page.reindexObject(idxs=["Subject"])
processQueue()

self.request.form["name"] = "plone.app.vocabularies.Keywords"
results = getMultiAdapter((self.portal, self.request), name="getVocabulary")()
results = json.loads(results)
result = results["results"][0]

self.assertEqual(result["text"], test_val)
self.assertEqual(result["id"], test_val)

def testVocabularyUnauthorized(self):
setRoles(self.portal, TEST_USER_ID, [])
view = VocabularyView(self.portal, self.request)
Expand Down

0 comments on commit 850b8a2

Please sign in to comment.