Skip to content

Commit

Permalink
remove CMFDefault dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed May 29, 2015
1 parent 254065e commit df2de9c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 14 deletions.
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

0 comments on commit df2de9c

Please sign in to comment.