|
14 | 14 | from Products.CMFCore.utils import getToolByName
|
15 | 15 | from Products.MimetypesRegistry.MimeTypeItem import guess_icon_path
|
16 | 16 | from Products.MimetypesRegistry.MimeTypeItem import PREFIX
|
| 17 | +from Products.PortalTransforms.transforms.safe_html import hasScript |
17 | 18 | from Products.PortalTransforms.transforms.safe_html import SafeHTML
|
18 | 19 | from zope.i18n import translate
|
19 | 20 |
|
20 | 21 | import itertools
|
21 | 22 |
|
22 | 23 |
|
23 | 24 | class RecensioVocabularyView(VocabularyView):
|
| 25 | + def maybe_scrub(self, value): |
| 26 | + if value and (hasScript(value) or "<" in value): |
| 27 | + transform = SafeHTML() |
| 28 | + return transform.scrub_html(value) |
| 29 | + return value |
| 30 | + |
24 | 31 | def __call__(self): # noqa: C901
|
25 | 32 | """
|
26 | 33 | Accepts GET parameters of:
|
@@ -103,7 +110,6 @@ def __call__(self): # noqa: C901
|
103 | 110 | attributes = attributes.split(",")
|
104 | 111 |
|
105 | 112 | translate_ignored = self.get_translated_ignored()
|
106 |
| - transform = SafeHTML() |
107 | 113 | if attributes:
|
108 | 114 | base_path = self.get_base_path(context)
|
109 | 115 | sm = getSecurityManager()
|
@@ -154,15 +160,15 @@ def __call__(self): # noqa: C901
|
154 | 160 | else:
|
155 | 161 | items = [
|
156 | 162 | {
|
157 |
| - "id": item.value, |
158 |
| - "text": (item.title if item.title else ""), |
| 163 | + "id": unescape(self.maybe_scrub(item.value)), |
| 164 | + "text": ( |
| 165 | + unescape(self.maybe_scrub(item.title)) if item.title else "" |
| 166 | + ), |
159 | 167 | }
|
160 | 168 | for item in results
|
161 | 169 | ]
|
162 | 170 |
|
163 | 171 | if total == 0:
|
164 | 172 | total = len(items)
|
165 | 173 |
|
166 |
| - return unescape( |
167 |
| - transform.scrub_html(json_dumps({"results": items, "total": total})) |
168 |
| - ) |
| 174 | + return json_dumps({"results": items, "total": total}) |
0 commit comments