Module Expr Str Import alias ImportFrom alias alias alias ImportFrom alias alias alias alias Assign NameStore ListLoad Str Str Assign NameStore Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Dict Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore NameStore NameStore NameStore NameLoad Assign NameStore NameStore NameStore NameLoad Assign NameStore NameLoad Assign NameStore ListLoad Assign NameStore NameLoad For TupleStore NameStore NameStore NameStore NameLoad body If CompareIs NameLoad NameLoad body Assign TupleStore NameStore NameStore NameLoad Assign NameStore AttributeLoad NameLoad attr If BoolOpAnd CompareEq NameLoad Str BoolOpOr BoolOpAnd AttributeLoad NameLoad attr CompareEq Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr BoolOpAnd AttributeLoad NameLoad attr CompareEq Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr UnaryOpNot BoolOpOr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore NameLoad orelse If NameLoad body If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr Str If CompareIn NameLoad TupleLoad Str Str body Assign NameStore Call AttributeLoad NameLoad attr Str If BoolOpAnd NameLoad CompareIn NameLoad AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore NameLoad If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body If NameLoad body Assign NameStore CompareIn NameLoad ListComp Call NameLoad NameLoad comprehension NameStore NameLoad orelse Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad orelse If NameLoad body Assign NameStore CompareEq NameLoad Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call NameLoad NameLoad If NameLoad body AugAssignBitOr NameStore ListLoad TupleLoad Call NameLoad Str Str orelse If CompareIn Str NameLoad body AugAssignSub NameStore Str orelse If CompareIn NameLoad TupleLoad NameLoad Str Str body Assign NameStore Call AttributeLoad NameLoad attr Str If BoolOpAnd NameLoad CompareIn NameLoad AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index Num If CompareIsNot NameLoad NameLoad body AugAssignBitOr NameStore ListLoad TupleLoad Call NameLoad Str Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr Str If CompareIn NameLoad AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr Str If CompareIn NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore NameLoad orelse If BoolOpAnd NameLoad CompareEq NameLoad Str body Assign NameStore TupleLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str If CompareIs NameLoad NameLoad body Assign NameStore NameLoad Assign NameStore Str Assign NameStore NameLoad Continue Expr Yield TupleLoad NameLoad TupleLoad NameLoad NameLoad NameLoad orelse If BoolOpAnd NameLoad CompareIs NameLoad NameLoad body If BoolOpAnd NameLoad NameLoad body If NameLoad body AugAssignAdd NameStore NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad NameLoad Continue orelse If NameLoad body Continue Expr Yield TupleLoad NameLoad NameLoad NameLoad orelse If BoolOpAnd NameLoad CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr If CompareEq NameLoad Str body Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore NameLoad Assign NameStore NameLoad orelse If BoolOpAnd NameLoad CompareEq NameLoad Str body If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore CompareIn NameLoad ListComp Call NameLoad NameLoad comprehension NameStore NameLoad orelse Assign NameStore CompareEq NameLoad Call NameLoad NameLoad Assign TupleStore NameStore TupleStore NameStore NameStore NameStore NameLoad If NameLoad body AugAssignBitOr NameStore ListLoad TupleLoad Call NameLoad Str Str orelse If CompareIn Str NameLoad body AugAssignSub NameStore Str Expr Yield TupleLoad NameLoad TupleLoad NameLoad NameLoad NameLoad If NameLoad body For NameStore NameLoad body Expr Yield NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameStore NameLoad Assign NameStore ListLoad orelse If CompareEq NameLoad Str body If NameLoad body Expr Yield TupleLoad NameLoad Call NameLoad NameLoad NameLoad Assign NameStore NameLoad Expr Yield TupleLoad NameLoad NameLoad NameLoad orelse Expr Yield TupleLoad NameLoad NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore Call NameLoad ListLoad Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Assign NameStore Call NameLoad ListLoad Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Assign NameStore Call NameLoad ListLoad Str Str Str Str Str NameLoad Assign NameStore Call NameLoad ListLoad Str Str Str Str Str Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore NameLoad For TupleStore NameStore NameStore NameStore NameLoad body If CompareIs NameLoad NameLoad body If NameLoad body Continue Assign TupleStore NameStore NameStore NameLoad If CompareNotIn NameLoad AttributeLoad NameLoad attr body Assign NameStore NameLoad Continue Assign NameStore ListLoad For TupleStore NameStore NameStore NameLoad body Assign NameStore Call NameLoad NameLoad If CompareNotIn NameLoad AttributeLoad NameLoad attr body Continue orelse If CompareIn NameLoad AttributeLoad NameLoad attr body If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Continue orelse If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Continue Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Expr Yield TupleLoad NameLoad TupleLoad NameLoad Call NameLoad NameLoad NameLoad orelse If CompareIs NameLoad NameLoad body Assign NameStore NameLoad If NameLoad body If CompareEq NameLoad NameLoad body Assign NameStore NameLoad orelse Expr Yield TupleLoad NameLoad NameLoad NameLoad orelse If CompareIsNot NameLoad NameLoad body If UnaryOpNot NameLoad body Expr Yield TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareNotIn Str NameLoad body Return NameLoad Assign NameStore ListComp NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Num Index Num Call AttributeLoad NameLoad attr Return CompareIn Call AttributeLoad Call AttributeLoad Str attr NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad For NameStore Call NameLoad NameLoad Call AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Continue Assign NameStore NameLoad If CompareIn Str NameLoad body Assign NameStore NameLoad For NameStore Call AttributeLoad NameLoad attr Str NameLoad body If UnaryOpNot Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num body Assign NameStore NameLoad Break If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Return NameLoad decorator_list Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr Str attr Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr Str attr FunctionDef arguments args NameParam NameParam defaults body FunctionDef arguments args NameParam defaults body Return Call NameLoad Call NameLoad Call AttributeLoad NameLoad attr Num Num decorator_list Return Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Str NameLoad decorator_list Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr Str attr FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr Str NameLoad decorator_list decorator_list
N/A N/A Implementation of a number of stream filters. N/A re genshi.core Attrs QName stripentities genshi.core END START TEXT COMMENT N/A __all__ N/A HTMLFormFiller HTMLSanitizer N/A __docformat__ restructuredtext en HTMLFormFiller N/A object N/A N/A A stream filter that can populate HTML forms from a dictionary of values.
    
    >>> from genshi.input import HTML
    >>> html = HTML('''<form>
    ...   <p><input type="text" name="foo" /></p>
    ... </form>''')
    >>> filler = HTMLFormFiller(data={'foo': 'bar'})
    >>> print html | filler
    <form>
      <p><input type="text" name="foo" value="bar"/></p>
    </form>
     __init__ N/A N/A self name id data N/A None None None N/A N/A Create the filter.
        
        :param name: The name of the form that should be populated. If this
                     parameter is given, only forms where the ``name`` attribute
                     value matches the parameter are processed.
        :param id: The ID of the form that should be populated. If this
                   parameter is given, only forms where the ``id`` attribute
                   value matches the parameter are processed.
        :param data: The dictionary of form values, where the keys are the names
                     of the form fields, and the values are the values to fill
                     in.
         N/A N/A self name name N/A N/A self id id N/A N/A data None N/A N/A data N/A N/A N/A self data data N/A __call__ N/A N/A self stream N/A N/A N/A Apply the filter to the given stream.
        
        :param stream: the markup event stream to filter
         N/A in_form in_select in_option in_textarea False N/A select_value option_value textarea_value None N/A option_start None N/A option_text N/A N/A no_option_value False N/A N/A kind data pos stream N/A N/A N/A kind START N/A N/A N/A tag attrs data N/A tagname N/A tag localname N/A N/A N/A tagname form N/A N/A N/A self name N/A N/A N/A attrs get name N/A self name N/A N/A self id N/A N/A N/A attrs get id N/A self id N/A N/A N/A self id N/A self name N/A N/A in_form True N/A N/A in_form N/A N/A N/A tagname input N/A N/A type N/A N/A attrs get type N/A N/A type N/A checkbox radio N/A N/A name N/A N/A attrs get name N/A N/A name N/A name N/A self data N/A N/A value N/A N/A self data N/A name N/A declval N/A N/A attrs get value N/A checked False N/A N/A isinstance value N/A list tuple N/A N/A declval N/A N/A checked N/A declval N/A N/A unicode v N/A v value N/A N/A checked N/A bool N/A filter None value N/A N/A declval N/A N/A checked N/A declval N/A unicode value N/A N/A N/A type checkbox N/A N/A checked N/A bool value N/A checked N/A N/A attrs N/A N/A N/A QName checked checked N/A N/A N/A checked attrs N/A N/A attrs checked N/A N/A N/A type N/A None hidden text N/A N/A name N/A N/A attrs get name N/A N/A name N/A name N/A self data N/A N/A value N/A N/A self data N/A name N/A N/A isinstance value N/A list tuple N/A N/A value N/A value N/A 0 N/A N/A value None N/A N/A attrs N/A N/A N/A QName value N/A unicode value N/A N/A N/A tagname select N/A N/A name N/A N/A attrs get name N/A N/A name N/A self data N/A N/A select_value N/A N/A self data N/A name N/A in_select True N/A N/A N/A tagname textarea N/A N/A name N/A N/A attrs get name N/A N/A name N/A self data N/A N/A textarea_value N/A N/A N/A self data get name N/A N/A isinstance textarea_value N/A list tuple N/A N/A textarea_value N/A textarea_value N/A 0 N/A in_textarea True N/A N/A N/A in_select N/A tagname option N/A N/A option_start N/A kind data pos N/A option_value N/A N/A attrs get value N/A N/A option_value None N/A N/A no_option_value True N/A option_value N/A in_option True N/A N/A N/A N/A kind N/A tag attrs pos N/A N/A N/A in_form N/A kind TEXT N/A N/A N/A in_select in_option N/A N/A no_option_value N/A N/A option_value data N/A N/A N/A option_text append N/A kind data pos N/A N/A N/A in_textarea N/A N/A N/A N/A N/A kind data pos N/A N/A N/A in_form N/A kind END N/A N/A tagname N/A data localname N/A N/A tagname form N/A N/A in_form False N/A N/A N/A tagname select N/A N/A in_select False N/A select_value None N/A N/A N/A in_select N/A tagname option N/A N/A N/A isinstance select_value N/A tuple list N/A N/A selected N/A option_value N/A N/A unicode v N/A v select_value N/A N/A selected N/A option_value N/A unicode select_value N/A N/A okind N/A tag attrs opos option_start N/A selected N/A N/A attrs N/A N/A N/A QName selected selected N/A N/A N/A selected attrs N/A N/A attrs selected N/A N/A N/A okind N/A tag attrs opos N/A option_text N/A N/A event option_text N/A N/A N/A event N/A in_option False N/A no_option_value False N/A option_start option_value None N/A option_text N/A N/A N/A N/A tagname textarea N/A N/A textarea_value N/A N/A N/A N/A TEXT N/A unicode textarea_value pos N/A in_textarea False N/A N/A N/A kind data pos N/A N/A N/A N/A kind data pos N/A N/A HTMLSanitizer N/A object N/A N/A A filter that removes potentially dangerous HTML tags and attributes
    from the stream.
    
    >>> from genshi import HTML
    >>> html = HTML('<div><script>alert(document.cookie)</script></div>')
    >>> print html | HTMLSanitizer()
    <div/>
    
    The default set of safe tags and attributes can be modified when the filter
    is instantiated. For example, to allow inline ``style`` attributes, the
    following instantation would work:
    
    >>> html = HTML('<div style="background: #000"></div>')
    >>> sanitizer = HTMLSanitizer(safe_attrs=HTMLSanitizer.SAFE_ATTRS | set(['style']))
    >>> print html | sanitizer
    <div style="background: #000"/>
    
    Note that even in this case, the filter *does* attempt to remove dangerous
    constructs from style attributes:

    >>> html = HTML('<div style="background: url(javascript:void); color: #000"></div>')
    >>> print html | sanitizer
    <div style="color: #000"/>
    
    This handles HTML entities, unicode escapes in CSS and Javascript text, as
    well as a lot of other things. However, the style tag is still excluded by
    default because it is very hard for such sanitizing to be completely safe,
    especially considering how much error recovery current web browsers perform.
    
    :warn: Note that this special processing of CSS is currently only applied to
           style attributes, **not** style elements.
     N/A SAFE_TAGS N/A frozenset N/A a abbr acronym address area b big blockquote br button caption center cite code col colgroup dd del dfn dir div dl dt em fieldset font form h1 h2 h3 h4 h5 h6 hr i img input ins kbd label legend li map menu ol optgroup option p pre q s samp select small span strike strong sub sup table tbody td textarea tfoot th thead tr tt u ul var N/A SAFE_ATTRS N/A frozenset N/A abbr accept accept-charset accesskey action align alt axis bgcolor border cellpadding cellspacing char charoff charset checked cite class clear cols colspan color compact coords datetime dir disabled enctype for frame headers height href hreflang hspace id ismap label lang longdesc maxlength media method multiple name nohref noshade nowrap prompt readonly rel rev rows rowspan rules scope selected shape size span src start summary tabindex target title type usemap valign value vspace width N/A SAFE_SCHEMES N/A frozenset N/A file ftp http https mailto None N/A URI_ATTRS N/A frozenset N/A action background dynsrc href lowsrc src __init__ N/A N/A self safe_tags safe_attrs safe_schemes uri_attrs N/A SAFE_TAGS SAFE_ATTRS SAFE_SCHEMES URI_ATTRS N/A N/A Create the sanitizer.
        
        The exact set of allowed elements and attributes can be configured.
        
        :param safe_tags: a set of tag names that are considered safe
        :param safe_attrs: a set of attribute names that are considered safe
        :param safe_schemes: a set of URI schemes that are considered safe
        :param uri_attrs: a set of names of attributes that contain URIs
         N/A N/A self safe_tags safe_tags N/A The set of tag names that are considered safe. N/A N/A self safe_attrs safe_attrs N/A The set of attribute names that are considered safe. N/A N/A self uri_attrs uri_attrs N/A The set of names of attributes that may contain URIs. N/A N/A self safe_schemes safe_schemes N/A The set of URI schemes that are considered safe. N/A __call__ N/A N/A self stream N/A N/A N/A Apply the filter to the given stream.
        
        :param stream: the markup event stream to filter
         N/A waiting_for None N/A N/A kind data pos stream N/A N/A N/A kind START N/A N/A waiting_for N/A N/A N/A N/A tag attrs data N/A N/A tag N/A self safe_tags N/A N/A waiting_for tag N/A N/A new_attrs N/A N/A N/A attr value attrs N/A N/A value N/A stripentities value N/A N/A attr N/A self safe_attrs N/A N/A N/A N/A N/A attr N/A self uri_attrs N/A N/A N/A N/A N/A self is_safe_uri value N/A N/A N/A N/A N/A attr style N/A N/A decls N/A N/A self sanitize_css value N/A N/A decls N/A N/A N/A value N/A N/A ;  join decls N/A N/A N/A new_attrs append N/A attr value N/A N/A N/A kind N/A tag N/A Attrs new_attrs pos N/A N/A N/A kind END N/A N/A tag data N/A waiting_for N/A N/A N/A waiting_for tag N/A N/A waiting_for None N/A N/A N/A N/A kind data pos N/A N/A N/A kind COMMENT N/A N/A N/A waiting_for N/A N/A N/A N/A kind data pos N/A is_safe_uri N/A N/A self uri N/A N/A N/A Determine whether the given URI is to be considered safe for
        inclusion in the output.
        
        The default implementation checks whether the scheme of the URI is in
        the set of allowed URIs (`safe_schemes`).
        
        >>> sanitizer = HTMLSanitizer()
        >>> sanitizer.is_safe_uri('http://example.org/')
        True
        >>> sanitizer.is_safe_uri('javascript:alert(document.cookie)')
        False
        
        :param uri: the URI to check
        :return: `True` if the URI can be considered safe, `False` otherwise
        :rtype: `bool`
        :since: version 0.4.3
         N/A N/A : uri N/A N/A True N/A chars N/A char N/A char N/A N/A N/A uri split : 1 N/A 0 N/A N/A char isalnum N/A N/A N/A N/A N/A N/A join chars lower N/A self safe_schemes N/A sanitize_css N/A N/A self text N/A N/A N/A Remove potentially dangerous property declarations from CSS code.
        
        In particular, properties using the CSS ``url()`` function with a scheme
        that is not considered safe are removed:
        
        >>> sanitizer = HTMLSanitizer()
        >>> sanitizer.sanitize_css(u'''
        ...   background: url(javascript:alert("foo"));
        ...   color: #000;
        ... ''')
        [u'color: #000']
        
        Also, the proprietary Internet Explorer function ``expression()`` is
        always stripped:
        
        >>> sanitizer.sanitize_css(u'''
        ...   background: #fff;
        ...   color: #000;
        ...   width: e/**/xpression(alert("foo"));
        ... ''')
        [u'background: #fff', u'color: #000']
        
        :param text: the CSS text; this is expected to be `unicode` and to not
                     contain any character or numeric references
        :return: a list of declarations that are considered safe
        :rtype: `list`
        :since: version 0.4.3
         N/A decls N/A N/A text N/A N/A self _strip_css_comments N/A N/A self _replace_unicode_escapes text N/A decl N/A filter None N/A N/A text split ; N/A N/A decl N/A N/A decl strip N/A N/A decl N/A N/A N/A is_evil False N/A N/A expression decl N/A N/A is_evil True N/A match N/A N/A re finditer url\s*\(([^)]+) decl N/A N/A N/A N/A N/A self is_safe_uri N/A N/A match group 1 N/A N/A is_evil True N/A N/A N/A is_evil N/A N/A N/A N/A decls append N/A N/A decl strip N/A decls N/A N/A _NORMALIZE_NEWLINES N/A N/A N/A re compile \r\n sub N/A _UNICODE_ESCAPE N/A N/A N/A re compile \\([0-9a-fA-F]{1,6})\s? sub _replace_unicode_escapes N/A N/A self text N/A N/A _repl N/A N/A match N/A N/A N/A N/A unichr N/A int N/A N/A match group 1 16 N/A N/A N/A N/A self _UNICODE_ESCAPE _repl N/A N/A self _NORMALIZE_NEWLINES text N/A N/A _CSS_COMMENTS N/A N/A N/A re compile /\*.*?\*/ sub _strip_css_comments N/A N/A self text N/A N/A N/A N/A N/A self _CSS_COMMENTS text N/A N/A