We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Unnecessary css file tries to load while editing a page
While editing a page an unnecessary css file tries to load:
![unnecessary_css](https://user-images.githubusercontent.com/5301889/57622531-2353a180-758e-11e9-9c5b-5d3cdef9a9b0.jpg)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `Products/CMFPlone/patterns/tinymce.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from lxml import html
3 from plone.app.layout.navigation.root import getNavigationRootObject
4 from plone.app.theming.utils import theming_policy
5 from plone.registry.interfaces import IRegistry
6 from Products.CMFCore.utils import getToolByName
7 from Products.CMFPlone.interfaces import IFilterSchema
8 from Products.CMFPlone.interfaces import ITinyMCESchema
9 from Products.CMFPlone.utils import get_portal
10 from Products.CMFPlone.utils import safe_unicode
11 from zope.component import getUtility
12 
13 import json
14 
15 
16 class TinyMCESettingsGenerator(object):
17 
18     def __init__(self, context, request):
19         self.context = context
20         self.request = request
21         self.settings = getUtility(IRegistry).forInterface(
22             ITinyMCESchema,
23             prefix="plone",
24             check=False
25         )
26         self.filter_settings = getUtility(IRegistry).forInterface(
27             IFilterSchema,
28             prefix="plone",
29             check=False
30         )
31         self.nav_root = getNavigationRootObject(
32             self.context,
33             get_portal(),
34         )
35         self.nav_root_url = self.nav_root.absolute_url()
36 
37     def get_theme(self):
38         return theming_policy().get_theme()
39 
40     def get_content_css(self, style_css=''):
41         files = [
42             '{0}/++plone++static/plone-compiled.css'.format(self.nav_root_url)
43         ]
44         if style_css:
45             files.extend(style_css.split(','))
46         content_css = self.settings.content_css or []
47         for url in content_css:
48             if url and url.strip():
49                 files.append('/'.join([self.nav_root_url, url.strip()]))
50         theme = self.get_theme()
51         tinymce_content_css = getattr(theme, 'tinymce_content_css', None)
52         if tinymce_content_css is not None:
53             for path in theme.tinymce_content_css.split(','):
54                 if path.startswith('http://') or path.startswith('https://'):
55                     files.append(path)
56                 else:
57                     files.append(self.nav_root_url + path)
58 
59         return ','.join(files)
60 
61     def get_style_format(self, txt, _type='format', base=None):
62         parts = txt.strip().split('|')
63         if len(parts) < 2:
64             return
65         if base is None:
66             val = {}
67         else:
68             val = base.copy()
69         val.update({
70             'title': parts[0],
71             _type: parts[1]
72         })
73         if len(parts) > 2:
74             val['icon'] = parts[2]
75         return val
76 
77     def get_styles(self, styles, _type='format', base=None):
78         result = []
79         for style in styles:
80             style = self.get_style_format(style, _type, base)
81             if not style:
82                 continue
83             result.append(style)
84         return result
85 
86     def get_all_style_formats(self):
87         header_styles = self.settings.header_styles or []
88         block_styles = self.settings.block_styles or []
89         inline_styles = self.settings.inline_styles or []
90         alignment_styles = self.settings.alignment_styles or []
91         table_styles = self.settings.table_styles or []
92         style_formats = [{
93             'title': 'Headers',
94             'items': self.get_styles(header_styles)
95         }, {
96             'title': 'Block',
97             'items': self.get_styles(block_styles)
98         }, {
99             'title': 'Inline',
100             'items': self.get_styles(inline_styles)
101         }, {
102             'title': 'Alignment',
103             'items': self.get_styles(alignment_styles)
104         }, {
105             'title': 'Tables',
106             'items': self.get_styles(
107                 table_styles, 'classes', {'selector': 'table'})
108         }]
109         return [sf for sf in style_formats if sf['items']]
110 
111     def get_tiny_config(self):
112         settings = self.settings
113         importcss_file_filter = '%s/++plone++static/tinymce-styles.css' % (
114             self.nav_root_url
115         )
116 
117         theme = self.get_theme()
118         if theme and getattr(theme, 'tinymce_styles_css', None):
119             importcss_file_filter += ',%s/%s' % (
120                 self.nav_root_url,
121                 theme.tinymce_styles_css.lstrip('/'))
122 
123         tiny_config = {
124             'resize': 'both' if settings.resizing else False,
125             'content_css': self.get_content_css(importcss_file_filter),
126             'plugins': [
127                 'plonelink',
128                 'ploneimage',
129                 'importcss'
130             ] + settings.plugins,
131             'external_plugins': {},
132             'toolbar': settings.toolbar,
133             'entity_encoding': settings.entity_encoding,
134             'importcss_append': True,
135             'importcss_file_filter': importcss_file_filter,
136             'browser_spellcheck': True
137         }
138         toolbar_additions = settings.custom_buttons or []
139 
140         if settings.editor_height:
141             tiny_config['height'] = settings.editor_height
142         if settings.autoresize:
143             tiny_config['plugins'].append('autoresize')
144             tiny_config['autoresize_max_height'] = 1000  # hard coded?
145         if settings.editor_width:
146             tiny_config['width'] = settings.editor_width
147 
148         # specific plugin options
149         if 'contextmenu' in settings.plugins:
150             tiny_config['contextmenu'] = "plonelink ploneimage inserttable |"\
151                 " cell row column deletetable"
152 
153         if settings.libraries_spellchecker_choice == 'AtD':
154             mtool = getToolByName(self.context, 'portal_membership')
155             member = mtool.getAuthenticatedMember()
156             member_id = member.getId()
157             if member_id:
158                 if 'compat3x' not in tiny_config['plugins']:
159                     tiny_config['plugins'].append('compat3x')
160                 tiny_config['external_plugins']['AtD'] = (
161                     '{0}/++plone++static/tinymce-AtD-plugin/'
162                     'editor_plugin.js'.format(self.nav_root_url)
163                 )
164                 # None when Anonymous User
165                 tiny_config['atd_rpc_id'] = 'plone-' + member_id
166                 tiny_config['atd_rpc_url'] = self.nav_root_url
167                 tiny_config['atd_show_types'] = ','.join(
168                     settings.libraries_atd_show_types
169                 )
170                 tiny_config['atd_ignore_strings'] = ','.join(
171                     settings.libraries_atd_ignore_strings
172                 )
173                 toolbar_additions.append('AtD')
174         elif settings.libraries_spellchecker_choice == 'AtD':
175             tiny_config['browser_spellcheck'] = True
176 
177         if toolbar_additions:
178             tiny_config['toolbar'] += ' | {0}'.format(
179                 ' '.join(toolbar_additions)
180             )
181 
182         for plugin in settings.custom_plugins or []:
183             parts = plugin.split('|')
184             if len(parts) != 2:
185                 continue
186             tiny_config['external_plugins'][parts[0]] = parts[1]
187 
188         tiny_config['style_formats'] = self.get_all_style_formats()
189         if settings.formats:
190             try:
191                 tiny_config['formats'] = json.loads(settings.formats)
192             except ValueError:
193                 pass
194 
195         if settings.menubar:
196             tiny_config['menubar'] = settings.menubar
197         if settings.menu:
198             try:
199                 tiny_config['menu'] = json.loads(settings.menu)
200             except ValueError:
201                 pass
202 
203         if hasattr(settings, 'templates') and settings.templates:
204             try:
205                 tiny_config['templates'] = json.loads(settings.templates)
206             except ValueError:
207                 pass
208 
209         # add safe_html settings, which are useed in backend for filtering:
210         if not self.filter_settings.disable_filtering:
211             valid_tags = self.filter_settings.valid_tags
212             nasty_tags = self.filter_settings.nasty_tags
213             custom_attributes = self.filter_settings.custom_attributes
214             safe_attributes = [
215                 safe_unicode(attr) for attr in html.defs.safe_attrs]
216             valid_attributes = safe_attributes + custom_attributes
217             # valid_elements : 'a[href|target=_blank],strong/b,div[align],br'
218             tiny_valid_elements = []
219             for tag in valid_tags:
220                 tag_str = "%s[%s]" % (tag, "|".join(valid_attributes))
221                 tiny_valid_elements.append(tag_str)
222             # We want to remove the nasty tag including the content in the
223             # backend, so TinyMCE should allow them here.
224             for tag in nasty_tags:
225                 tag_str = "%s[%s]" % (tag, "|".join(valid_attributes))
226                 tiny_valid_elements.append(tag_str)
227             tiny_config['valid_elements'] = ",".join(tiny_valid_elements)
228 
229         if settings.other_settings:
230             try:
231                 tiny_config.update(json.loads(settings.other_settings))
232             except ValueError:
233                 pass
234 
235         return tiny_config
236
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/Products/CMFPlone/patterns/tinymce.py b/Products/CMFPlone/patterns/tinymce.py
--- a/Products/CMFPlone/patterns/tinymce.py
+++ b/Products/CMFPlone/patterns/tinymce.py
@@ -49,7 +49,7 @@
                 files.append('/'.join([self.nav_root_url, url.strip()]))
         theme = self.get_theme()
         tinymce_content_css = getattr(theme, 'tinymce_content_css', None)
-        if tinymce_content_css is not None:
+        if tinymce_content_css is not None and tinymce_content_css != '':
             for path in theme.tinymce_content_css.split(','):
                 if path.startswith('http://') or path.startswith('https://'):
                     files.append(path)

{"golden_diff": "diff --git a/Products/CMFPlone/patterns/tinymce.py b/Products/CMFPlone/patterns/tinymce.py\n--- a/Products/CMFPlone/patterns/tinymce.py\n+++ b/Products/CMFPlone/patterns/tinymce.py\n@@ -49,7 +49,7 @@\n                 files.append('/'.join([self.nav_root_url, url.strip()]))\n         theme = self.get_theme()\n         tinymce_content_css = getattr(theme, 'tinymce_content_css', None)\n-        if tinymce_content_css is not None:\n+        if tinymce_content_css is not None and tinymce_content_css != '':\n             for path in theme.tinymce_content_css.split(','):\n                 if path.startswith('http://') or path.startswith('https://'):\n                     files.append(path)\n", "issue": "Unnecessary css file tries to load while editing a page\nWhile editing a page an unnecessary css file tries to load:\r\n![unnecessary_css](https://user-images.githubusercontent.com/5301889/57622531-2353a180-758e-11e9-9c5b-5d3cdef9a9b0.jpg)\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom lxml import html\nfrom plone.app.layout.navigation.root import getNavigationRootObject\nfrom plone.app.theming.utils import theming_policy\nfrom plone.registry.interfaces import IRegistry\nfrom Products.CMFCore.utils import getToolByName\nfrom Products.CMFPlone.interfaces import IFilterSchema\nfrom Products.CMFPlone.interfaces import ITinyMCESchema\nfrom Products.CMFPlone.utils import get_portal\nfrom Products.CMFPlone.utils import safe_unicode\nfrom zope.component import getUtility\n\nimport json\n\n\nclass TinyMCESettingsGenerator(object):\n\n    def __init__(self, context, request):\n        self.context = context\n        self.request = request\n        self.settings = getUtility(IRegistry).forInterface(\n            ITinyMCESchema,\n            prefix=\"plone\",\n            check=False\n        )\n        self.filter_settings = getUtility(IRegistry).forInterface(\n            IFilterSchema,\n            prefix=\"plone\",\n            check=False\n        )\n        self.nav_root = getNavigationRootObject(\n            self.context,\n            get_portal(),\n        )\n        self.nav_root_url = self.nav_root.absolute_url()\n\n    def get_theme(self):\n        return theming_policy().get_theme()\n\n    def get_content_css(self, style_css=''):\n        files = [\n            '{0}/++plone++static/plone-compiled.css'.format(self.nav_root_url)\n        ]\n        if style_css:\n            files.extend(style_css.split(','))\n        content_css = self.settings.content_css or []\n        for url in content_css:\n            if url and url.strip():\n                files.append('/'.join([self.nav_root_url, url.strip()]))\n        theme = self.get_theme()\n        tinymce_content_css = getattr(theme, 'tinymce_content_css', None)\n        if tinymce_content_css is not None:\n            for path in theme.tinymce_content_css.split(','):\n                if path.startswith('http://') or path.startswith('https://'):\n                    files.append(path)\n                else:\n                    files.append(self.nav_root_url + path)\n\n        return ','.join(files)\n\n    def get_style_format(self, txt, _type='format', base=None):\n        parts = txt.strip().split('|')\n        if len(parts) < 2:\n            return\n        if base is None:\n            val = {}\n        else:\n            val = base.copy()\n        val.update({\n            'title': parts[0],\n            _type: parts[1]\n        })\n        if len(parts) > 2:\n            val['icon'] = parts[2]\n        return val\n\n    def get_styles(self, styles, _type='format', base=None):\n        result = []\n        for style in styles:\n            style = self.get_style_format(style, _type, base)\n            if not style:\n                continue\n            result.append(style)\n        return result\n\n    def get_all_style_formats(self):\n        header_styles = self.settings.header_styles or []\n        block_styles = self.settings.block_styles or []\n        inline_styles = self.settings.inline_styles or []\n        alignment_styles = self.settings.alignment_styles or []\n        table_styles = self.settings.table_styles or []\n        style_formats = [{\n            'title': 'Headers',\n            'items': self.get_styles(header_styles)\n        }, {\n            'title': 'Block',\n            'items': self.get_styles(block_styles)\n        }, {\n            'title': 'Inline',\n            'items': self.get_styles(inline_styles)\n        }, {\n            'title': 'Alignment',\n            'items': self.get_styles(alignment_styles)\n        }, {\n            'title': 'Tables',\n            'items': self.get_styles(\n                table_styles, 'classes', {'selector': 'table'})\n        }]\n        return [sf for sf in style_formats if sf['items']]\n\n    def get_tiny_config(self):\n        settings = self.settings\n        importcss_file_filter = '%s/++plone++static/tinymce-styles.css' % (\n            self.nav_root_url\n        )\n\n        theme = self.get_theme()\n        if theme and getattr(theme, 'tinymce_styles_css', None):\n            importcss_file_filter += ',%s/%s' % (\n                self.nav_root_url,\n                theme.tinymce_styles_css.lstrip('/'))\n\n        tiny_config = {\n            'resize': 'both' if settings.resizing else False,\n            'content_css': self.get_content_css(importcss_file_filter),\n            'plugins': [\n                'plonelink',\n                'ploneimage',\n                'importcss'\n            ] + settings.plugins,\n            'external_plugins': {},\n            'toolbar': settings.toolbar,\n            'entity_encoding': settings.entity_encoding,\n            'importcss_append': True,\n            'importcss_file_filter': importcss_file_filter,\n            'browser_spellcheck': True\n        }\n        toolbar_additions = settings.custom_buttons or []\n\n        if settings.editor_height:\n            tiny_config['height'] = settings.editor_height\n        if settings.autoresize:\n            tiny_config['plugins'].append('autoresize')\n            tiny_config['autoresize_max_height'] = 1000  # hard coded?\n        if settings.editor_width:\n            tiny_config['width'] = settings.editor_width\n\n        # specific plugin options\n        if 'contextmenu' in settings.plugins:\n            tiny_config['contextmenu'] = \"plonelink ploneimage inserttable |\"\\\n                \" cell row column deletetable\"\n\n        if settings.libraries_spellchecker_choice == 'AtD':\n            mtool = getToolByName(self.context, 'portal_membership')\n            member = mtool.getAuthenticatedMember()\n            member_id = member.getId()\n            if member_id:\n                if 'compat3x' not in tiny_config['plugins']:\n                    tiny_config['plugins'].append('compat3x')\n                tiny_config['external_plugins']['AtD'] = (\n                    '{0}/++plone++static/tinymce-AtD-plugin/'\n                    'editor_plugin.js'.format(self.nav_root_url)\n                )\n                # None when Anonymous User\n                tiny_config['atd_rpc_id'] = 'plone-' + member_id\n                tiny_config['atd_rpc_url'] = self.nav_root_url\n                tiny_config['atd_show_types'] = ','.join(\n                    settings.libraries_atd_show_types\n                )\n                tiny_config['atd_ignore_strings'] = ','.join(\n                    settings.libraries_atd_ignore_strings\n                )\n                toolbar_additions.append('AtD')\n        elif settings.libraries_spellchecker_choice == 'AtD':\n            tiny_config['browser_spellcheck'] = True\n\n        if toolbar_additions:\n            tiny_config['toolbar'] += ' | {0}'.format(\n                ' '.join(toolbar_additions)\n            )\n\n        for plugin in settings.custom_plugins or []:\n            parts = plugin.split('|')\n            if len(parts) != 2:\n                continue\n            tiny_config['external_plugins'][parts[0]] = parts[1]\n\n        tiny_config['style_formats'] = self.get_all_style_formats()\n        if settings.formats:\n            try:\n                tiny_config['formats'] = json.loads(settings.formats)\n            except ValueError:\n                pass\n\n        if settings.menubar:\n            tiny_config['menubar'] = settings.menubar\n        if settings.menu:\n            try:\n                tiny_config['menu'] = json.loads(settings.menu)\n            except ValueError:\n                pass\n\n        if hasattr(settings, 'templates') and settings.templates:\n            try:\n                tiny_config['templates'] = json.loads(settings.templates)\n            except ValueError:\n                pass\n\n        # add safe_html settings, which are useed in backend for filtering:\n        if not self.filter_settings.disable_filtering:\n            valid_tags = self.filter_settings.valid_tags\n            nasty_tags = self.filter_settings.nasty_tags\n            custom_attributes = self.filter_settings.custom_attributes\n            safe_attributes = [\n                safe_unicode(attr) for attr in html.defs.safe_attrs]\n            valid_attributes = safe_attributes + custom_attributes\n            # valid_elements : 'a[href|target=_blank],strong/b,div[align],br'\n            tiny_valid_elements = []\n            for tag in valid_tags:\n                tag_str = \"%s[%s]\" % (tag, \"|\".join(valid_attributes))\n                tiny_valid_elements.append(tag_str)\n            # We want to remove the nasty tag including the content in the\n            # backend, so TinyMCE should allow them here.\n            for tag in nasty_tags:\n                tag_str = \"%s[%s]\" % (tag, \"|\".join(valid_attributes))\n                tiny_valid_elements.append(tag_str)\n            tiny_config['valid_elements'] = \",\".join(tiny_valid_elements)\n\n        if settings.other_settings:\n            try:\n                tiny_config.update(json.loads(settings.other_settings))\n            except ValueError:\n                pass\n\n        return tiny_config\n", "path": "Products/CMFPlone/patterns/tinymce.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom lxml import html\nfrom plone.app.layout.navigation.root import getNavigationRootObject\nfrom plone.app.theming.utils import theming_policy\nfrom plone.registry.interfaces import IRegistry\nfrom Products.CMFCore.utils import getToolByName\nfrom Products.CMFPlone.interfaces import IFilterSchema\nfrom Products.CMFPlone.interfaces import ITinyMCESchema\nfrom Products.CMFPlone.utils import get_portal\nfrom Products.CMFPlone.utils import safe_unicode\nfrom zope.component import getUtility\n\nimport json\n\n\nclass TinyMCESettingsGenerator(object):\n\n    def __init__(self, context, request):\n        self.context = context\n        self.request = request\n        self.settings = getUtility(IRegistry).forInterface(\n            ITinyMCESchema,\n            prefix=\"plone\",\n            check=False\n        )\n        self.filter_settings = getUtility(IRegistry).forInterface(\n            IFilterSchema,\n            prefix=\"plone\",\n            check=False\n        )\n        self.nav_root = getNavigationRootObject(\n            self.context,\n            get_portal(),\n        )\n        self.nav_root_url = self.nav_root.absolute_url()\n\n    def get_theme(self):\n        return theming_policy().get_theme()\n\n    def get_content_css(self, style_css=''):\n        files = [\n            '{0}/++plone++static/plone-compiled.css'.format(self.nav_root_url)\n        ]\n        if style_css:\n            files.extend(style_css.split(','))\n        content_css = self.settings.content_css or []\n        for url in content_css:\n            if url and url.strip():\n                files.append('/'.join([self.nav_root_url, url.strip()]))\n        theme = self.get_theme()\n        tinymce_content_css = getattr(theme, 'tinymce_content_css', None)\n        if tinymce_content_css is not None and tinymce_content_css != '':\n            for path in theme.tinymce_content_css.split(','):\n                if path.startswith('http://') or path.startswith('https://'):\n                    files.append(path)\n                else:\n                    files.append(self.nav_root_url + path)\n\n        return ','.join(files)\n\n    def get_style_format(self, txt, _type='format', base=None):\n        parts = txt.strip().split('|')\n        if len(parts) < 2:\n            return\n        if base is None:\n            val = {}\n        else:\n            val = base.copy()\n        val.update({\n            'title': parts[0],\n            _type: parts[1]\n        })\n        if len(parts) > 2:\n            val['icon'] = parts[2]\n        return val\n\n    def get_styles(self, styles, _type='format', base=None):\n        result = []\n        for style in styles:\n            style = self.get_style_format(style, _type, base)\n            if not style:\n                continue\n            result.append(style)\n        return result\n\n    def get_all_style_formats(self):\n        header_styles = self.settings.header_styles or []\n        block_styles = self.settings.block_styles or []\n        inline_styles = self.settings.inline_styles or []\n        alignment_styles = self.settings.alignment_styles or []\n        table_styles = self.settings.table_styles or []\n        style_formats = [{\n            'title': 'Headers',\n            'items': self.get_styles(header_styles)\n        }, {\n            'title': 'Block',\n            'items': self.get_styles(block_styles)\n        }, {\n            'title': 'Inline',\n            'items': self.get_styles(inline_styles)\n        }, {\n            'title': 'Alignment',\n            'items': self.get_styles(alignment_styles)\n        }, {\n            'title': 'Tables',\n            'items': self.get_styles(\n                table_styles, 'classes', {'selector': 'table'})\n        }]\n        return [sf for sf in style_formats if sf['items']]\n\n    def get_tiny_config(self):\n        settings = self.settings\n        importcss_file_filter = '%s/++plone++static/tinymce-styles.css' % (\n            self.nav_root_url\n        )\n\n        theme = self.get_theme()\n        if theme and getattr(theme, 'tinymce_styles_css', None):\n            importcss_file_filter += ',%s/%s' % (\n                self.nav_root_url,\n                theme.tinymce_styles_css.lstrip('/'))\n\n        tiny_config = {\n            'resize': 'both' if settings.resizing else False,\n            'content_css': self.get_content_css(importcss_file_filter),\n            'plugins': [\n                'plonelink',\n                'ploneimage',\n                'importcss'\n            ] + settings.plugins,\n            'external_plugins': {},\n            'toolbar': settings.toolbar,\n            'entity_encoding': settings.entity_encoding,\n            'importcss_append': True,\n            'importcss_file_filter': importcss_file_filter,\n            'browser_spellcheck': True\n        }\n        toolbar_additions = settings.custom_buttons or []\n\n        if settings.editor_height:\n            tiny_config['height'] = settings.editor_height\n        if settings.autoresize:\n            tiny_config['plugins'].append('autoresize')\n            tiny_config['autoresize_max_height'] = 1000  # hard coded?\n        if settings.editor_width:\n            tiny_config['width'] = settings.editor_width\n\n        # specific plugin options\n        if 'contextmenu' in settings.plugins:\n            tiny_config['contextmenu'] = \"plonelink ploneimage inserttable |\"\\\n                \" cell row column deletetable\"\n\n        if settings.libraries_spellchecker_choice == 'AtD':\n            mtool = getToolByName(self.context, 'portal_membership')\n            member = mtool.getAuthenticatedMember()\n            member_id = member.getId()\n            if member_id:\n                if 'compat3x' not in tiny_config['plugins']:\n                    tiny_config['plugins'].append('compat3x')\n                tiny_config['external_plugins']['AtD'] = (\n                    '{0}/++plone++static/tinymce-AtD-plugin/'\n                    'editor_plugin.js'.format(self.nav_root_url)\n                )\n                # None when Anonymous User\n                tiny_config['atd_rpc_id'] = 'plone-' + member_id\n                tiny_config['atd_rpc_url'] = self.nav_root_url\n                tiny_config['atd_show_types'] = ','.join(\n                    settings.libraries_atd_show_types\n                )\n                tiny_config['atd_ignore_strings'] = ','.join(\n                    settings.libraries_atd_ignore_strings\n                )\n                toolbar_additions.append('AtD')\n        elif settings.libraries_spellchecker_choice == 'AtD':\n            tiny_config['browser_spellcheck'] = True\n\n        if toolbar_additions:\n            tiny_config['toolbar'] += ' | {0}'.format(\n                ' '.join(toolbar_additions)\n            )\n\n        for plugin in settings.custom_plugins or []:\n            parts = plugin.split('|')\n            if len(parts) != 2:\n                continue\n            tiny_config['external_plugins'][parts[0]] = parts[1]\n\n        tiny_config['style_formats'] = self.get_all_style_formats()\n        if settings.formats:\n            try:\n                tiny_config['formats'] = json.loads(settings.formats)\n            except ValueError:\n                pass\n\n        if settings.menubar:\n            tiny_config['menubar'] = settings.menubar\n        if settings.menu:\n            try:\n                tiny_config['menu'] = json.loads(settings.menu)\n            except ValueError:\n                pass\n\n        if hasattr(settings, 'templates') and settings.templates:\n            try:\n                tiny_config['templates'] = json.loads(settings.templates)\n            except ValueError:\n                pass\n\n        # add safe_html settings, which are useed in backend for filtering:\n        if not self.filter_settings.disable_filtering:\n            valid_tags = self.filter_settings.valid_tags\n            nasty_tags = self.filter_settings.nasty_tags\n            custom_attributes = self.filter_settings.custom_attributes\n            safe_attributes = [\n                safe_unicode(attr) for attr in html.defs.safe_attrs]\n            valid_attributes = safe_attributes + custom_attributes\n            # valid_elements : 'a[href|target=_blank],strong/b,div[align],br'\n            tiny_valid_elements = []\n            for tag in valid_tags:\n                tag_str = \"%s[%s]\" % (tag, \"|\".join(valid_attributes))\n                tiny_valid_elements.append(tag_str)\n            # We want to remove the nasty tag including the content in the\n            # backend, so TinyMCE should allow them here.\n            for tag in nasty_tags:\n                tag_str = \"%s[%s]\" % (tag, \"|\".join(valid_attributes))\n                tiny_valid_elements.append(tag_str)\n            tiny_config['valid_elements'] = \",\".join(tiny_valid_elements)\n\n        if settings.other_settings:\n            try:\n                tiny_config.update(json.loads(settings.other_settings))\n            except ValueError:\n                pass\n\n        return tiny_config\n", "path": "Products/CMFPlone/patterns/tinymce.py"}]}