[silva.core.upgrade][Emiliano D'Alterio] Added upgrader to 3.0.3...
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Emiliano D'Alterio date: Mon Aug 26 16:38:57 2013 +0200 revision: 349:c18d3984ef9e in silva.core.upgrade branch: 2.4 details: https://hg.infrae.com/silva.core.upgrade?cmd=changeset;node=c18d3984ef9e modified: src/silva/core/upgrade/upgrader/upgrade_303.py added: src/silva/core/upgrade/upgrader/upgrade_303.py removed: log: Added upgrader to 3.0.3 for the new HTML Sanitizer defaults. diffstat: src/silva/core/upgrade/upgrader/upgrade_303.py | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diffs (30 lines): diff -r e85a803c0150 -r c18d3984ef9e src/silva/core/upgrade/upgrader/upgrade_303.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/silva/core/upgrade/upgrader/upgrade_303.py Mon Aug 26 16:38:57 2013 +0200 @@ -0,0 +1,26 @@ +from silva.core.upgrade.upgrade import BaseUpgrader +from silva.core.editor.utils import DEFAULT_PER_TAG_WHITELISTS +from silva.core.editor.utils import DEFAULT_HTML_ATTR_WHITELIST +from silva.core.editor.utils import DEFAULT_CSS_PROP_WHITELIST + + +VERSION = '3.0.3' + + +class CKEditorServiceUpgrader(BaseUpgrader): + """Upgrade a pre-existing Sanitizer configuration object. + """ + + def upgrade(self, service): + if '_per_tag_allowed_attr' not in service.__dict__: + service.__dict__['_per_tag_allowed_attr'] = set( + DEFAULT_PER_TAG_WHITELISTS) + if '_allowed_html_tags' in service.__dict__: + del service.__dict__['_allowed_html_tags'] + service._allowed_html_attributes = set(DEFAULT_HTML_ATTR_WHITELIST) + service._allowed_css_attributes = set(DEFAULT_CSS_PROP_WHITELIST) + + return service + +ckeditor_service_upgrader = CKEditorServiceUpgrader(VERSION, + 'Silva CKEditor Service')