witten
/
luminotes
Archived
1
0
Fork 0

Made Html_cleaner support many more HTML tags and attributes, so users can

cut and paste from other programs into Luminotes.
This commit is contained in:
Dan Helfman 2008-03-31 00:31:13 +00:00
parent 0a5af3d9c0
commit b403e5419c
2 changed files with 98 additions and 1 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
1.2.21: March 30, 2008
* Made Html_cleaner support many more HTML tags and attributes, so users can
cut and paste from other programs into Luminotes.
1.2.20: March 29, 2008
* Fixed a bug in which closing a Luminotes window with an unsaved note in
Firefox would occasionally not save it.

View File

@ -37,6 +37,77 @@ class Html_cleaner(HTMLParser):
'p',
'strong',
'u',
'div',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'q',
'cite',
'code',
'samp',
'kbd',
'var',
'dfn',
'address',
'big',
'small',
'ins',
'del',
'acronym',
'abbr',
'strike',
's',
'sub',
'sup',
'tt',
'pre',
'center',
'font',
'basefont',
'multicol',
'spacer',
'layer',
'ilayer',
'nolayer',
'img',
'map',
'area',
'param',
'hr',
'nobr',
'wbr',
'ul',
'ol',
'li',
'dl',
'dt',
'dd',
'menu',
'dir',
'form',
'input',
'button',
'label',
'select',
'option',
'optgroup',
'textarea',
'fieldset',
'legend',
'table',
'tr',
'td',
'th',
'tbody',
'tfoot',
'thead',
'caption',
'col',
'colgroup',
]
# A list of tags that are forcibly removed from the input. Tags that
@ -44,6 +115,22 @@ class Html_cleaner(HTMLParser):
# escaped.
self.stripped_tags = [
'span',
'blink',
'marquee',
'bgsound',
'meta',
'object',
'iframe',
'script',
'noscript',
'applet',
'embed',
'style',
'link',
'html',
'title',
'head',
'body',
]
# A list of tags that require no closing tag.
@ -55,11 +142,17 @@ class Html_cleaner(HTMLParser):
# of "background" and "style."
self.allowed_attributes = {
'a': [ 'href', 'target' ],
'p': [ 'align' ],
'img': [ 'alt', 'border', 'title' ],
'table': [ 'cellpadding', 'cellspacing', 'border', 'width', 'height' ],
'font': [ 'color', 'size', 'face' ],
'td': [ 'rowspan', 'colspan', 'width', 'height' ],
'th': [ 'rowspan', 'colspan', 'width', 'height' ],
}
# The only schemes allowed in URLs (for href and src attributes).
# Adding "javascript" or "vbscript" to this list would not be smart.
self.allowed_schemes = ['http','https','ftp', '']
self.allowed_schemes = ['http','https','ftp', 'irc', '']
def handle_data(self, data):
if data: