Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
plone.app.portlets.portlets.feedparser._RelativeURIResolver Class Reference
Inheritance diagram for plone.app.portlets.portlets.feedparser._RelativeURIResolver:
Inheritance graph
[legend]
Collaboration diagram for plone.app.portlets.portlets.feedparser._RelativeURIResolver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def resolveURI
def unknown_starttag
def reset
def feed
def normalize_attrs
def unknown_endtag
def handle_charref
def handle_entityref
def handle_data
def handle_comment
def handle_pi
def handle_decl
def output

Public Attributes

 baseuri
 encoding
 pieces

Static Public Attributes

list relative_uris
list elements_no_end_tag

Detailed Description

Definition at line 1552 of file feedparser.py.


Constructor & Destructor Documentation

Definition at line 1579 of file feedparser.py.

01579 
01580     def __init__(self, baseuri, encoding):
01581         _BaseHTMLProcessor.__init__(self, encoding)
01582         self.baseuri = baseuri

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1433 of file feedparser.py.

01433 
01434     def feed(self, data):
01435         data = re.compile(r'<!((?!DOCTYPE|--|\[))', re.IGNORECASE).sub(r'&lt;!\1', data)
01436         #data = re.sub(r'<(\S+?)\s*?/>', self._shorttag_replace, data) # bug [ 1399464 ] Bad regexp for _shorttag_replace
01437         data = re.sub(r'<([^<\s]+?)\s*/>', self._shorttag_replace, data) 
01438         data = data.replace('&#39;', "'")
01439         data = data.replace('&#34;', '"')
01440         if self.encoding and type(data) == type(u''):
01441             data = data.encode(self.encoding)
01442         sgmllib.SGMLParser.feed(self, data)

Here is the call graph for this function:

Definition at line 1472 of file feedparser.py.

01472 
01473     def handle_charref(self, ref):
01474         # called for each character reference, e.g. for '&#160;', ref will be '160'
01475         # Reconstruct the original character reference.
01476         self.pieces.append('&#%(ref)s;' % locals())
        

Definition at line 1489 of file feedparser.py.

01489 
01490     def handle_comment(self, text):
01491         # called for each HTML comment, e.g. <!-- insert Javascript code here -->
01492         # Reconstruct the original comment.
01493         self.pieces.append('<!--%(text)s-->' % locals())
        

Reimplemented in plone.app.portlets.portlets.feedparser._HTMLSanitizer.

Definition at line 1482 of file feedparser.py.

01482 
01483     def handle_data(self, text):
01484         # called for each block of plain text, i.e. outside of any tag and
01485         # not containing any character or entity references
01486         # Store the original text verbatim.
01487         if _debug: sys.stderr.write('_BaseHTMLProcessor, handle_text, text=%s\n' % text)
01488         self.pieces.append(text)
        

Here is the caller graph for this function:

Reimplemented in plone.app.portlets.portlets.feedparser._HTMLSanitizer.

Definition at line 1499 of file feedparser.py.

01499 
01500     def handle_decl(self, text):
01501         # called for the DOCTYPE, if present, e.g.
01502         # <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
01503         #     "http://www.w3.org/TR/html4/loose.dtd">
01504         # Reconstruct original DOCTYPE
01505         self.pieces.append('<!%(text)s>' % locals())
        

Definition at line 1477 of file feedparser.py.

01477 
01478     def handle_entityref(self, ref):
01479         # called for each entity reference, e.g. for '&copy;', ref will be 'copy'
01480         # Reconstruct the original entity reference.
01481         self.pieces.append('&%(ref)s;' % locals())

Reimplemented in plone.app.portlets.portlets.feedparser._HTMLSanitizer.

Definition at line 1494 of file feedparser.py.

01494 
01495     def handle_pi(self, text):
01496         # called for each processing instruction, e.g. <?instruction>
01497         # Reconstruct original processing instruction.
01498         self.pieces.append('<?%(text)s>' % locals())

Definition at line 1443 of file feedparser.py.

01443 
01444     def normalize_attrs(self, attrs):
01445         # utility method to be called by descendants
01446         attrs = [(k.lower(), v) for k, v in attrs]
01447         attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs]
01448         return attrs

Here is the caller graph for this function:

Return processed HTML as a single string

Definition at line 1524 of file feedparser.py.

01524 
01525     def output(self):
01526         '''Return processed HTML as a single string'''
01527         return ''.join([str(p) for p in self.pieces])

Here is the caller graph for this function:

Reimplemented in plone.app.portlets.portlets.feedparser._HTMLSanitizer.

Definition at line 1422 of file feedparser.py.

01422 
01423     def reset(self):
01424         self.pieces = []
01425         sgmllib.SGMLParser.reset(self)

Here is the caller graph for this function:

Definition at line 1583 of file feedparser.py.

01583 
01584     def resolveURI(self, uri):
01585         return _urljoin(self.baseuri, uri)
    

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in plone.app.portlets.portlets.feedparser._HTMLSanitizer.

Definition at line 1466 of file feedparser.py.

01466 
01467     def unknown_endtag(self, tag):
01468         # called for each end tag, e.g. for </pre>, tag will be 'pre'
01469         # Reconstruct the original end tag.
01470         if tag not in self.elements_no_end_tag:
01471             self.pieces.append("</%(tag)s>" % locals())

Reimplemented from plone.app.portlets.portlets.feedparser._BaseHTMLProcessor.

Definition at line 1586 of file feedparser.py.

01586 
01587     def unknown_starttag(self, tag, attrs):
01588         attrs = self.normalize_attrs(attrs)
01589         attrs = [(key, ((tag, key) in self.relative_uris) and self.resolveURI(value) or value) for key, value in attrs]
01590         _BaseHTMLProcessor.unknown_starttag(self, tag, attrs)
        

Here is the call graph for this function:


Member Data Documentation

Definition at line 1581 of file feedparser.py.

Initial value:
['area', 'base', 'basefont', 'br', 'col', 'frame', 'hr',
      'img', 'input', 'isindex', 'link', 'meta', 'param']

Definition at line 1414 of file feedparser.py.

Definition at line 1418 of file feedparser.py.

Definition at line 1423 of file feedparser.py.

Initial value:
[('a', 'href'),
                     ('applet', 'codebase'),
                     ('area', 'href'),
                     ('blockquote', 'cite'),
                     ('body', 'background'),
                     ('del', 'cite'),
                     ('form', 'action'),
                     ('frame', 'longdesc'),
                     ('frame', 'src'),
                     ('iframe', 'longdesc'),
                     ('iframe', 'src'),
                     ('head', 'profile'),
                     ('img', 'longdesc'),
                     ('img', 'src'),
                     ('img', 'usemap'),
                     ('input', 'src'),
                     ('input', 'usemap'),
                     ('ins', 'cite'),
                     ('link', 'href'),
                     ('object', 'classid'),
                     ('object', 'codebase'),
                     ('object', 'data'),
                     ('object', 'usemap'),
                     ('q', 'cite'),
                     ('script', 'src')]

Definition at line 1553 of file feedparser.py.


The documentation for this class was generated from the following file: