Skip to content

Commit

Permalink
Merge pull request #8 from plone/tomgross-nocmfdefault2
Browse files Browse the repository at this point in the history
Removed CMFDefault dependency
  • Loading branch information
tisto committed May 30, 2015
2 parents 254065e + d4749b6 commit 070647c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.1.7 (unreleased)
------------------

- Nothing changed yet.
- Remove CMFDefault dependency
[tomgross]


2.1.6 (2015-04-22)
Expand Down
2 changes: 1 addition & 1 deletion Products/PortalTransforms/transforms/html_body.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Products.PortalTransforms.interfaces import ITransform
from zope.interface import implements
from Products.CMFDefault.utils import bodyfinder
from Products.PortalTransforms.libtransforms.utils import bodyfinder


class HTMLBody:
Expand Down
2 changes: 1 addition & 1 deletion Products/PortalTransforms/transforms/pdf_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from Products.PortalTransforms.libtransforms.utils import sansext
from Products.PortalTransforms.libtransforms.commandtransform import (
commandtransform, popentransform)
from Products.CMFDefault.utils import bodyfinder
from Products.PortalTransforms.libtransforms.utils import bodyfinder
import os


Expand Down
2 changes: 1 addition & 1 deletion Products/PortalTransforms/transforms/rtf_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from Products.PortalTransforms.interfaces import ITransform
from zope.interface import implements
from Products.PortalTransforms.libtransforms.utils import sansext
from Products.PortalTransforms.libtransforms.utils import bodyfinder
from Products.PortalTransforms.libtransforms.commandtransform import \
commandtransform
from Products.CMFDefault.utils import bodyfinder
import os


Expand Down
76 changes: 65 additions & 11 deletions Products/PortalTransforms/transforms/safe_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,74 @@
from Products.PortalTransforms.interfaces import ITransform
from zope.interface import implements
from Products.PortalTransforms.utils import log
from Products.CMFDefault.utils import bodyfinder
from Products.CMFDefault.utils import IllegalHTML
from Products.CMFDefault.utils import VALID_TAGS
from Products.CMFDefault.utils import NASTY_TAGS
from Products.PortalTransforms.libtransforms.utils import bodyfinder
from Products.PortalTransforms.utils import safeToInt

# tag mapping: tag -> short or long tag
VALID_TAGS = VALID_TAGS.copy()
NASTY_TAGS = NASTY_TAGS.copy()
class IllegalHTML(ValueError):
""" Illegal HTML error.
"""


# These are the HTML tags that we will leave intact
VALID_TAGS = { 'a' : 1
, 'b' : 1
, 'base' : 0
, 'big' : 1
, 'blockquote' : 1
, 'body' : 1
, 'br' : 0
, 'caption' : 1
, 'cite' : 1
, 'code' : 1
, 'dd' : 1
, 'div' : 1
, 'dl' : 1
, 'dt' : 1
, 'em' : 1
, 'h1' : 1
, 'h2' : 1
, 'h3' : 1
, 'h4' : 1
, 'h5' : 1
, 'h6' : 1
, 'head' : 1
, 'hr' : 0
, 'html' : 1
, 'i' : 1
, 'img' : 0
, 'kbd' : 1
, 'li' : 1
# , 'link' : 1 type="script" hoses us
, 'meta' : 0
, 'ol' : 1
, 'p' : 1
, 'pre' : 1
, 'small' : 1
, 'span' : 1
, 'strong' : 1
, 'sub' : 1
, 'sup' : 1
, 'table' : 1
, 'tbody' : 1
, 'td' : 1
, 'th' : 1
, 'title' : 1
, 'tr' : 1
, 'tt' : 1
, 'u' : 1
, 'ul' : 1
}

NASTY_TAGS = { 'script' : 1
, 'object' : 1
, 'embed' : 1
, 'applet' : 1
, 'style' : 1 # this helps improve Word HTML cleanup.
, 'meta' : 1 # allowed by parsers, but can cause unexpected behavior
}


# add some tags to allowed types. These should be backported to CMFDefault.
# add some tags to allowed types.
VALID_TAGS['ins'] = 1
VALID_TAGS['del'] = 1
VALID_TAGS['q'] = 1
Expand Down Expand Up @@ -61,9 +118,6 @@
VALID_TAGS['time'] = 1
VALID_TAGS['video'] = 1

# add some tags to nasty.
NASTY_TAGS['style'] = 1 # this helps improve Word HTML cleanup.
NASTY_TAGS['meta'] = 1 # allowed by parsers, but can cause unexpected behavior


msg_pat = """
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
'zope.interface',
'zope.structuredtext',
'Products.CMFCore',
'Products.CMFDefault',
'Products.MimetypesRegistry',
'Acquisition',
'ZODB3',
Expand Down

1 comment on commit 070647c

@mauritsvanrees
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, Plone 4.3 uses the master branch too. Is this change safe for 4.3? It might be.

I have checked it out in coredev 4.3, let's see what Travis says.
plone/buildout.coredev@4434520

Please sign in to comment.