Example #1
0
scrubber.allowed_tags = set((
    'a',
    'abbr',
    'acronym',
    'b',
    'bdo',
    'big',
    'blockquote',
    'br',
    'center',
    'cite',
    'code',
    'dd',
    'del',
    'dfn',
    'div',
    'dl',
    'dt',
    'em',
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
    'hr',
    'i',
    'img',
    'ins',
    'kbd',
    'li',
    'ol',
    'param',
    'pre',
    'p',
    'q',
    's',
    'samp',
    'small',
    'span',
    'strike',
    'strong',
    'sub',
    'sup',
    'table',
    'tbody',
    'td',
    'th',
    'thead',
    'tr',
    'tt',
    'ul',
    'u',
    'var',
    'wbr',
))
import os
from scrubber import Scrubber
import BeautifulSoup
#import BeautifulSoup

# initialise the scrubber! all this stuff is overriding scrubber defaults so hack it to bits if you want!
scrubber = Scrubber(autolink=False)
scrubber.allowed_tags = set((
    'a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'blockquote', 'br',
    'center', 'cite', 'code',
    'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em',
    'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins',
    'kbd', 'li', 'ol', 'param', 'pre', 'p', 'q',
    's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup',
    'table', 'tbody', 'td', 'th', 'thead', 'tr', 'tt', 'ul', 'u',
    'var', 'wbr',
))
scrubber.disallowed_tags_save_content = set((
    'blink', 'body', 'html','font',
))
scrubber.allowed_attributes = set((
    'align', 'alt', 'border', 'cite', 'dir',
    'height', 'href', 'src', 'title', 'type', 'width',
    'face', 'size', # font tags
    'flashvars', # Not sure about flashvars - if any harm can come from it
    'classid', # FF needs the classid on object tags for flash
    'name', 'value', 'quality', 'data', 'scale', # for flash embed param tags, could limit to just param if this is harmful
    'salign', 'align', 'wmode',
)) # Bad attributes: 'allowscriptaccess', 'xmlns', 'target'
scrubber.normalized_tag_replacements = {'b': 'strong', 'i': 'em'}
# any giveaway classes the definately identify a footer.