__init__.py000064400000000000147205636440006656 0ustar00__init__.pyc000064400000000240147205636440007027 0ustar00 abc@sdS(N((((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/__init__.pytt__init__.pyo000064400000000240147205636440007043 0ustar00 abc@sdS(N((((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/__init__.pyttalphabeticalattributes.py000064400000001155147205636440011653 0ustar00from __future__ import absolute_import, division, unicode_literals from . import base try: from collections import OrderedDict except ImportError: from ordereddict import OrderedDict class Filter(base.Filter): def __iter__(self): for token in base.Filter.__iter__(self): if token["type"] in ("StartTag", "EmptyTag"): attrs = OrderedDict() for name, value in sorted(token["data"].items(), key=lambda x: x[0]): attrs[name] = value token["data"] = attrs yield token alphabeticalattributes.pyc000064400000002562147205636440012021 0ustar00 abc@`sddlmZmZmZddlmZyddlmZWn!ek rcddl mZnXdej fdYZ dS(i(tabsolute_importtdivisiontunicode_literalsi(tbase(t OrderedDicttFiltercB`seZdZRS(cc`sxtjj|D]k}|ddkryt}x7t|djddD]\}}|||t(uStartTaguEmptyTag(RRt__iter__Rtsortedtitems(tselfttokentattrstnametvalue((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyR s  (t__name__t __module__R (((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyR sN( t __future__RRRR Rt collectionsRt ImportErrort ordereddictR(((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyts  alphabeticalattributes.pyo000064400000002562147205636440012035 0ustar00 abc@`sddlmZmZmZddlmZyddlmZWn!ek rcddl mZnXdej fdYZ dS(i(tabsolute_importtdivisiontunicode_literalsi(tbase(t OrderedDicttFiltercB`seZdZRS(cc`sxtjj|D]k}|ddkryt}x7t|djddD]\}}|||t(uStartTaguEmptyTag(RRt__iter__Rtsortedtitems(tselfttokentattrstnametvalue((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyR s  (t__name__t __module__R (((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyR sN( t __future__RRRR Rt collectionsRt ImportErrort ordereddictR(((sW/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.pyts  base.py000064400000000436147205636440006046 0ustar00from __future__ import absolute_import, division, unicode_literals class Filter(object): def __init__(self, source): self.source = source def __iter__(self): return iter(self.source) def __getattr__(self, name): return getattr(self.source, name) base.pyc000064400000002122147205636440006203 0ustar00 abc@`s6ddlmZmZmZdefdYZdS(i(tabsolute_importtdivisiontunicode_literalstFiltercB`s#eZdZdZdZRS(cC`s ||_dS(N(tsource(tselfR((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt__init__scC`s t|jS(N(titerR(R((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt__iter__scC`st|j|S(N(tgetattrR(Rtname((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt __getattr__ s(t__name__t __module__RRR (((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyRs  N(t __future__RRRtobjectR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pytsbase.pyo000064400000002122147205636440006217 0ustar00 abc@`s6ddlmZmZmZdefdYZdS(i(tabsolute_importtdivisiontunicode_literalstFiltercB`s#eZdZdZdZRS(cC`s ||_dS(N(tsource(tselfR((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt__init__scC`s t|jS(N(titerR(R((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt__iter__scC`st|j|S(N(tgetattrR(Rtname((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyt __getattr__ s(t__name__t __module__RRR (((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pyRs  N(t __future__RRRtobjectR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/base.pytsinject_meta_charset.py000064400000005266147205636440011135 0ustar00from __future__ import absolute_import, division, unicode_literals from . import base class Filter(base.Filter): def __init__(self, source, encoding): base.Filter.__init__(self, source) self.encoding = encoding def __iter__(self): state = "pre_head" meta_found = (self.encoding is None) pending = [] for token in base.Filter.__iter__(self): type = token["type"] if type == "StartTag": if token["name"].lower() == "head": state = "in_head" elif type == "EmptyTag": if token["name"].lower() == "meta": # replace charset with actual encoding has_http_equiv_content_type = False for (namespace, name), value in token["data"].items(): if namespace is not None: continue elif name.lower() == 'charset': token["data"][(namespace, name)] = self.encoding meta_found = True break elif name == 'http-equiv' and value.lower() == 'content-type': has_http_equiv_content_type = True else: if has_http_equiv_content_type and (None, "content") in token["data"]: token["data"][(None, "content")] = 'text/html; charset=%s' % self.encoding meta_found = True elif token["name"].lower() == "head" and not meta_found: # insert meta into empty head yield {"type": "StartTag", "name": "head", "data": token["data"]} yield {"type": "EmptyTag", "name": "meta", "data": {(None, "charset"): self.encoding}} yield {"type": "EndTag", "name": "head"} meta_found = True continue elif type == "EndTag": if token["name"].lower() == "head" and pending: # insert meta into head (if necessary) and flush pending queue yield pending.pop(0) if not meta_found: yield {"type": "EmptyTag", "name": "meta", "data": {(None, "charset"): self.encoding}} while pending: yield pending.pop(0) meta_found = True state = "post_head" if state == "in_head": pending.append(token) else: yield token inject_meta_charset.pyc000064400000004315147205636440011272 0ustar00 abc@`sIddlmZmZmZddlmZdejfdYZdS(i(tabsolute_importtdivisiontunicode_literalsi(tbasetFiltercB`seZdZdZRS(cC`s tjj||||_dS(N(RRt__init__tencoding(tselftsourceR((sT/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/inject_meta_charset.pyRsc c`sd}|jdk}g}xvtjj|D]b}|d}|dkrl|djdkrod}qon|dkr|djdkr^t}xE|d jD]~\\}}} |dk rqq|jd kr|j|d ||fsinject_meta_charset.pyo000064400000004315147205636440011306 0ustar00 abc@`sIddlmZmZmZddlmZdejfdYZdS(i(tabsolute_importtdivisiontunicode_literalsi(tbasetFiltercB`seZdZdZRS(cC`s tjj||||_dS(N(RRt__init__tencoding(tselftsourceR((sT/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/inject_meta_charset.pyRsc c`sd}|jdk}g}xvtjj|D]b}|d}|dkrl|djdkrod}qon|dkr|djdkr^t}xE|d jD]~\\}}} |dk rqq|jd kr|j|d ||fslint.py000064400000006445147205636440006110 0ustar00from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type from . import base from ..constants import namespaces, voidElements from ..constants import spaceCharacters spaceCharacters = "".join(spaceCharacters) class Filter(base.Filter): def __init__(self, source, require_matching_tags=True): super(Filter, self).__init__(source) self.require_matching_tags = require_matching_tags def __iter__(self): open_elements = [] for token in base.Filter.__iter__(self): type = token["type"] if type in ("StartTag", "EmptyTag"): namespace = token["namespace"] name = token["name"] assert namespace is None or isinstance(namespace, text_type) assert namespace != "" assert isinstance(name, text_type) assert name != "" assert isinstance(token["data"], dict) if (not namespace or namespace == namespaces["html"]) and name in voidElements: assert type == "EmptyTag" else: assert type == "StartTag" if type == "StartTag" and self.require_matching_tags: open_elements.append((namespace, name)) for (namespace, name), value in token["data"].items(): assert namespace is None or isinstance(namespace, text_type) assert namespace != "" assert isinstance(name, text_type) assert name != "" assert isinstance(value, text_type) elif type == "EndTag": namespace = token["namespace"] name = token["name"] assert namespace is None or isinstance(namespace, text_type) assert namespace != "" assert isinstance(name, text_type) assert name != "" if (not namespace or namespace == namespaces["html"]) and name in voidElements: assert False, "Void element reported as EndTag token: %(tag)s" % {"tag": name} elif self.require_matching_tags: start = open_elements.pop() assert start == (namespace, name) elif type == "Comment": data = token["data"] assert isinstance(data, text_type) elif type in ("Characters", "SpaceCharacters"): data = token["data"] assert isinstance(data, text_type) assert data != "" if type == "SpaceCharacters": assert data.strip(spaceCharacters) == "" elif type == "Doctype": name = token["name"] assert name is None or isinstance(name, text_type) assert token["publicId"] is None or isinstance(name, text_type) assert token["systemId"] is None or isinstance(name, text_type) elif type == "Entity": assert isinstance(token["name"], text_type) elif type == "SerializerError": assert isinstance(token["data"], text_type) else: assert False, "Unknown token type: %(type)s" % {"type": type} yield token lint.pyc000064400000005726147205636440006254 0ustar00 abc@`sddlmZmZmZddlmZddlmZddlm Z m Z ddlm Z dj e Z d ej fd YZ d S( i(tabsolute_importtdivisiontunicode_literals(t text_typei(tbasei(t namespacest voidElements(tspaceCharactersutFiltercB`seZedZdZRS(cC`s#tt|j|||_dS(N(tsuperRt__init__trequire_matching_tags(tselftsourceR ((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyR sc c`sPg}xCtjj|D]/}|d}|dkr|d}|d}|dksjt|tsjt|dks|tt|tst|dkstt|dtst| s|tdkr|t kr|dkstn|dkst|dkr1|j r1|j ||fnx|dj D]\\}}}|dksut|tsut|dkstt|tst|dkstt|tsBtqBWny|d kr|d}|d}|dks t|ts t|dkstt|ts2t|dksDt| s[|tdkr|t krt std i|d 6qC|j rC|j}|||fkstqCn|d kr|d}t|tsCtn[|dkrR|d}t|tst|dks%t|dkrC|jtdksOtqCn|dkr|d}|dkst|tst|ddkst|tst|ddksCt|tsCtnm|dkrt|dtsCtnE|dkr&t|dtsCtnt sCtdi|d6|VqWdS(NutypeuStartTaguEmptyTagu namespaceunameuudatauhtmluEndTagu.Void element reported as EndTag token: %(tag)sutaguCommentu CharactersuSpaceCharactersuDoctypeupublicIdusystemIduEntityuSerializerErroruUnknown token type: %(type)s(uStartTaguEmptyTag(u CharactersuSpaceCharacters(RRt__iter__tNonet isinstanceRtAssertionErrortdictRRR tappendtitemstFalsetpoptstripR( R t open_elementsttokenttypet namespacetnametvaluetstarttdata((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyRsl    !##!   !#        !  !%(  (t__name__t __module__tTrueR R(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyR s N(t __future__RRRtpip._vendor.sixRtRt constantsRRRtjoinR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyts lint.pyo000064400000004075147205636440006264 0ustar00 abc@`sddlmZmZmZddlmZddlmZddlm Z m Z ddlm Z dj e Z d ej fd YZ d S( i(tabsolute_importtdivisiontunicode_literals(t text_typei(tbasei(t namespacest voidElements(tspaceCharactersutFiltercB`seZedZdZRS(cC`s#tt|j|||_dS(N(tsuperRt__init__trequire_matching_tags(tselftsourceR ((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyR sc c`sg}xtjj|D]}|d}|dkr|d}|d}| s`|tdkro|tkron|dkr|jr|j||fnx|djD]\\}}}qWn|dkr%|d}|d}| s|tdkr |tkr q|jr|j}qnx|d kr>|d}n_|dkrf|d}|d krqn7|d kr|d}n|d krn|dkrn|VqWdS(NutypeuStartTaguEmptyTagu namespaceunameuhtmludatauEndTaguCommentu CharactersuSpaceCharactersuDoctypeuEntityuSerializerError(uStartTaguEmptyTag(u CharactersuSpaceCharacters( RRt__iter__RRR tappendtitemstpop( R t open_elementsttokenttypet namespacetnametvaluetstarttdata((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyRsF    ##   #           (t__name__t __module__tTrueR R(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyR s N(t __future__RRRtpip._vendor.sixRtRt constantsRRRtjoinR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/lint.pyts optionaltags.py000064400000024446147205636440007647 0ustar00from __future__ import absolute_import, division, unicode_literals from . import base class Filter(base.Filter): def slider(self): previous1 = previous2 = None for token in self.source: if previous1 is not None: yield previous2, previous1, token previous2 = previous1 previous1 = token if previous1 is not None: yield previous2, previous1, None def __iter__(self): for previous, token, next in self.slider(): type = token["type"] if type == "StartTag": if (token["data"] or not self.is_optional_start(token["name"], previous, next)): yield token elif type == "EndTag": if not self.is_optional_end(token["name"], next): yield token else: yield token def is_optional_start(self, tagname, previous, next): type = next and next["type"] or None if tagname in 'html': # An html element's start tag may be omitted if the first thing # inside the html element is not a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname == 'head': # A head element's start tag may be omitted if the first thing # inside the head element is an element. # XXX: we also omit the start tag if the head element is empty if type in ("StartTag", "EmptyTag"): return True elif type == "EndTag": return next["name"] == "head" elif tagname == 'body': # A body element's start tag may be omitted if the first thing # inside the body element is not a space character or a comment, # except if the first thing inside the body element is a script # or style element and the node immediately preceding the body # element is a head element whose end tag has been omitted. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we do not look at the preceding event, so we never omit # the body element's start tag if it's followed by a script or # a style element. return next["name"] not in ('script', 'style') else: return True elif tagname == 'colgroup': # A colgroup element's start tag may be omitted if the first thing # inside the colgroup element is a col element, and if the element # is not immediately preceded by another colgroup element whose # end tag has been omitted. if type in ("StartTag", "EmptyTag"): # XXX: we do not look at the preceding event, so instead we never # omit the colgroup element's end tag when it is immediately # followed by another colgroup element. See is_optional_end. return next["name"] == "col" else: return False elif tagname == 'tbody': # A tbody element's start tag may be omitted if the first thing # inside the tbody element is a tr element, and if the element is # not immediately preceded by a tbody, thead, or tfoot element # whose end tag has been omitted. if type == "StartTag": # omit the thead and tfoot elements' end tag when they are # immediately followed by a tbody element. See is_optional_end. if previous and previous['type'] == 'EndTag' and \ previous['name'] in ('tbody', 'thead', 'tfoot'): return False return next["name"] == 'tr' else: return False return False def is_optional_end(self, tagname, next): type = next and next["type"] or None if tagname in ('html', 'head', 'body'): # An html element's end tag may be omitted if the html element # is not immediately followed by a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname in ('li', 'optgroup', 'tr'): # A li element's end tag may be omitted if the li element is # immediately followed by another li element or if there is # no more content in the parent element. # An optgroup element's end tag may be omitted if the optgroup # element is immediately followed by another optgroup element, # or if there is no more content in the parent element. # A tr element's end tag may be omitted if the tr element is # immediately followed by another tr element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] == tagname else: return type == "EndTag" or type is None elif tagname in ('dt', 'dd'): # A dt element's end tag may be omitted if the dt element is # immediately followed by another dt element or a dd element. # A dd element's end tag may be omitted if the dd element is # immediately followed by another dd element or a dt element, # or if there is no more content in the parent element. if type == "StartTag": return next["name"] in ('dt', 'dd') elif tagname == 'dd': return type == "EndTag" or type is None else: return False elif tagname == 'p': # A p element's end tag may be omitted if the p element is # immediately followed by an address, article, aside, # blockquote, datagrid, dialog, dir, div, dl, fieldset, # footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu, # nav, ol, p, pre, section, table, or ul, element, or if # there is no more content in the parent element. if type in ("StartTag", "EmptyTag"): return next["name"] in ('address', 'article', 'aside', 'blockquote', 'datagrid', 'dialog', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul') else: return type == "EndTag" or type is None elif tagname == 'option': # An option element's end tag may be omitted if the option # element is immediately followed by another option element, # or if it is immediately followed by an optgroup # element, or if there is no more content in the parent # element. if type == "StartTag": return next["name"] in ('option', 'optgroup') else: return type == "EndTag" or type is None elif tagname in ('rt', 'rp'): # An rt element's end tag may be omitted if the rt element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. # An rp element's end tag may be omitted if the rp element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('rt', 'rp') else: return type == "EndTag" or type is None elif tagname == 'colgroup': # A colgroup element's end tag may be omitted if the colgroup # element is not immediately followed by a space character or # a comment. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we also look for an immediately following colgroup # element. See is_optional_start. return next["name"] != 'colgroup' else: return True elif tagname in ('thead', 'tbody'): # A thead element's end tag may be omitted if the thead element # is immediately followed by a tbody or tfoot element. # A tbody element's end tag may be omitted if the tbody element # is immediately followed by a tbody or tfoot element, or if # there is no more content in the parent element. # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] in ['tbody', 'tfoot'] elif tagname == 'tbody': return type == "EndTag" or type is None else: return False elif tagname == 'tfoot': # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] == 'tbody' else: return type == "EndTag" or type is None elif tagname in ('td', 'th'): # A td element's end tag may be omitted if the td element is # immediately followed by a td or th element, or if there is # no more content in the parent element. # A th element's end tag may be omitted if the th element is # immediately followed by a td or th element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('td', 'th') else: return type == "EndTag" or type is None return False optionaltags.pyc000064400000010464147205636440010005 0ustar00 abc@`sIddlmZmZmZddlmZdejfdYZdS(i(tabsolute_importtdivisiontunicode_literalsi(tbasetFiltercB`s,eZdZdZdZdZRS(cc`shd}}x:|jD]/}|dk r7|||fVn|}|}qW|dk rd||dfVndS(N(tNonetsource(tselft previous1t previous2ttoken((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pytsliders    cc`sx|jD]\}}}|d}|dkra|dsV|j|d|| r|Vqq |dkr|j|d|s|Vqq |Vq WdS(NutypeuStartTagudataunameuEndTag(R tis_optional_starttis_optional_end(RtpreviousR tnextttype((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyt__iter__s      cC`s*|r|dpd}|dkr,|dkS|dkre|dkrHtS|dkr&|d dkSn|d kr|dkrtS|dkr|d dkStSn|d kr|dkr|d dkStSnW|dkr&|dkr|r|ddkr|d dkrtS|d dkStSntS(NutypeuhtmluCommentuSpaceCharactersuheaduStartTaguEmptyTaguEndTagunameubodyuscriptustyleucolgroupucolutbodyutheadutfootutr(uCommentuSpaceCharacters(uStartTaguEmptyTag(uCommentuSpaceCharacters(uscriptustyle(uStartTaguEmptyTag(utbodyutheadutfoot(RtTruetFalse(RttagnameRRR((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyR s4            cC`s|r|dpd}|d5kr,|d6kS|d7krk|d krR|d |kS|d kpg|dkSn|d8kr|d kr|d d9kS|dkr|d kp|dkStSn|dkr|d:kr|d d;kS|d kp|dkSn|d,kr8|d kr|d d<kS|d kp4|dkSnI|d=krw|d kr^|d d>kS|d kps|dkSn |d/kr|d?krtS|d kr|d d/kStSn|d@kr|d kr|d dAkS|d1kr|d kp|dkStSn~|d2krB|d kr)|d d1kS|d kp>|dkSn?|dBkr|d krh|d dCkS|d kp}|dkSntS(DNutypeuhtmluheadubodyuCommentuSpaceCharactersuliuoptgrouputruStartTagunameuEndTagudtuddupuEmptyTaguaddressuarticleuasideu blockquoteudatagridudialogudirudivudlufieldsetufooteruformuh1uh2uh3uh4uh5uh6uheaderuhrumenuunavuolupreusectionutableuuluoptionurturpucolgrouputheadutbodyutfootutduth(uhtmluheadubody(uCommentuSpaceCharacters(uliuoptgrouputr(udtudd(udtudd(uStartTaguEmptyTag(uaddressuarticleuasideu blockquoteudatagridudialogudirudivudlufieldsetufooteruformuh1uh2uh3uh4uh5uh6uheaderuhrumenuunavuolupupreusectionutableuul(uoptionuoptgroup(urturp(urturp(uCommentuSpaceCharacters(utheadutbody(utbodyutfoot(utduth(utduth(RRR(RRRR((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyR Wsf                     (t__name__t __module__R RR R (((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyRs 9N(t __future__RRRtRR(((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pytsoptionaltags.pyo000064400000010464147205636440010021 0ustar00 abc@`sIddlmZmZmZddlmZdejfdYZdS(i(tabsolute_importtdivisiontunicode_literalsi(tbasetFiltercB`s,eZdZdZdZdZRS(cc`shd}}x:|jD]/}|dk r7|||fVn|}|}qW|dk rd||dfVndS(N(tNonetsource(tselft previous1t previous2ttoken((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pytsliders    cc`sx|jD]\}}}|d}|dkra|dsV|j|d|| r|Vqq |dkr|j|d|s|Vqq |Vq WdS(NutypeuStartTagudataunameuEndTag(R tis_optional_starttis_optional_end(RtpreviousR tnextttype((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyt__iter__s      cC`s*|r|dpd}|dkr,|dkS|dkre|dkrHtS|dkr&|d dkSn|d kr|dkrtS|dkr|d dkStSn|d kr|dkr|d dkStSnW|dkr&|dkr|r|ddkr|d dkrtS|d dkStSntS(NutypeuhtmluCommentuSpaceCharactersuheaduStartTaguEmptyTaguEndTagunameubodyuscriptustyleucolgroupucolutbodyutheadutfootutr(uCommentuSpaceCharacters(uStartTaguEmptyTag(uCommentuSpaceCharacters(uscriptustyle(uStartTaguEmptyTag(utbodyutheadutfoot(RtTruetFalse(RttagnameRRR((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyR s4            cC`s|r|dpd}|d5kr,|d6kS|d7krk|d krR|d |kS|d kpg|dkSn|d8kr|d kr|d d9kS|dkr|d kp|dkStSn|dkr|d:kr|d d;kS|d kp|dkSn|d,kr8|d kr|d d<kS|d kp4|dkSnI|d=krw|d kr^|d d>kS|d kps|dkSn |d/kr|d?krtS|d kr|d d/kStSn|d@kr|d kr|d dAkS|d1kr|d kp|dkStSn~|d2krB|d kr)|d d1kS|d kp>|dkSn?|dBkr|d krh|d dCkS|d kp}|dkSntS(DNutypeuhtmluheadubodyuCommentuSpaceCharactersuliuoptgrouputruStartTagunameuEndTagudtuddupuEmptyTaguaddressuarticleuasideu blockquoteudatagridudialogudirudivudlufieldsetufooteruformuh1uh2uh3uh4uh5uh6uheaderuhrumenuunavuolupreusectionutableuuluoptionurturpucolgrouputheadutbodyutfootutduth(uhtmluheadubody(uCommentuSpaceCharacters(uliuoptgrouputr(udtudd(udtudd(uStartTaguEmptyTag(uaddressuarticleuasideu blockquoteudatagridudialogudirudivudlufieldsetufooteruformuh1uh2uh3uh4uh5uh6uheaderuhrumenuunavuolupupreusectionutableuul(uoptionuoptgroup(urturp(urturp(uCommentuSpaceCharacters(utheadutbody(utbodyutfoot(utduth(utduth(RRR(RRRR((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyR Wsf                     (t__name__t __module__R RR R (((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pyRs 9N(t __future__RRRtRR(((sM/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.pytssanitizer.py000064400000061030147205636440007141 0ustar00from __future__ import absolute_import, division, unicode_literals import re from xml.sax.saxutils import escape, unescape from pip._vendor.six.moves import urllib_parse as urlparse from . import base from ..constants import namespaces, prefixes __all__ = ["Filter"] allowed_elements = frozenset(( (namespaces['html'], 'a'), (namespaces['html'], 'abbr'), (namespaces['html'], 'acronym'), (namespaces['html'], 'address'), (namespaces['html'], 'area'), (namespaces['html'], 'article'), (namespaces['html'], 'aside'), (namespaces['html'], 'audio'), (namespaces['html'], 'b'), (namespaces['html'], 'big'), (namespaces['html'], 'blockquote'), (namespaces['html'], 'br'), (namespaces['html'], 'button'), (namespaces['html'], 'canvas'), (namespaces['html'], 'caption'), (namespaces['html'], 'center'), (namespaces['html'], 'cite'), (namespaces['html'], 'code'), (namespaces['html'], 'col'), (namespaces['html'], 'colgroup'), (namespaces['html'], 'command'), (namespaces['html'], 'datagrid'), (namespaces['html'], 'datalist'), (namespaces['html'], 'dd'), (namespaces['html'], 'del'), (namespaces['html'], 'details'), (namespaces['html'], 'dfn'), (namespaces['html'], 'dialog'), (namespaces['html'], 'dir'), (namespaces['html'], 'div'), (namespaces['html'], 'dl'), (namespaces['html'], 'dt'), (namespaces['html'], 'em'), (namespaces['html'], 'event-source'), (namespaces['html'], 'fieldset'), (namespaces['html'], 'figcaption'), (namespaces['html'], 'figure'), (namespaces['html'], 'footer'), (namespaces['html'], 'font'), (namespaces['html'], 'form'), (namespaces['html'], 'header'), (namespaces['html'], 'h1'), (namespaces['html'], 'h2'), (namespaces['html'], 'h3'), (namespaces['html'], 'h4'), (namespaces['html'], 'h5'), (namespaces['html'], 'h6'), (namespaces['html'], 'hr'), (namespaces['html'], 'i'), (namespaces['html'], 'img'), (namespaces['html'], 'input'), (namespaces['html'], 'ins'), (namespaces['html'], 'keygen'), (namespaces['html'], 'kbd'), (namespaces['html'], 'label'), (namespaces['html'], 'legend'), (namespaces['html'], 'li'), (namespaces['html'], 'm'), (namespaces['html'], 'map'), (namespaces['html'], 'menu'), (namespaces['html'], 'meter'), (namespaces['html'], 'multicol'), (namespaces['html'], 'nav'), (namespaces['html'], 'nextid'), (namespaces['html'], 'ol'), (namespaces['html'], 'output'), (namespaces['html'], 'optgroup'), (namespaces['html'], 'option'), (namespaces['html'], 'p'), (namespaces['html'], 'pre'), (namespaces['html'], 'progress'), (namespaces['html'], 'q'), (namespaces['html'], 's'), (namespaces['html'], 'samp'), (namespaces['html'], 'section'), (namespaces['html'], 'select'), (namespaces['html'], 'small'), (namespaces['html'], 'sound'), (namespaces['html'], 'source'), (namespaces['html'], 'spacer'), (namespaces['html'], 'span'), (namespaces['html'], 'strike'), (namespaces['html'], 'strong'), (namespaces['html'], 'sub'), (namespaces['html'], 'sup'), (namespaces['html'], 'table'), (namespaces['html'], 'tbody'), (namespaces['html'], 'td'), (namespaces['html'], 'textarea'), (namespaces['html'], 'time'), (namespaces['html'], 'tfoot'), (namespaces['html'], 'th'), (namespaces['html'], 'thead'), (namespaces['html'], 'tr'), (namespaces['html'], 'tt'), (namespaces['html'], 'u'), (namespaces['html'], 'ul'), (namespaces['html'], 'var'), (namespaces['html'], 'video'), (namespaces['mathml'], 'maction'), (namespaces['mathml'], 'math'), (namespaces['mathml'], 'merror'), (namespaces['mathml'], 'mfrac'), (namespaces['mathml'], 'mi'), (namespaces['mathml'], 'mmultiscripts'), (namespaces['mathml'], 'mn'), (namespaces['mathml'], 'mo'), (namespaces['mathml'], 'mover'), (namespaces['mathml'], 'mpadded'), (namespaces['mathml'], 'mphantom'), (namespaces['mathml'], 'mprescripts'), (namespaces['mathml'], 'mroot'), (namespaces['mathml'], 'mrow'), (namespaces['mathml'], 'mspace'), (namespaces['mathml'], 'msqrt'), (namespaces['mathml'], 'mstyle'), (namespaces['mathml'], 'msub'), (namespaces['mathml'], 'msubsup'), (namespaces['mathml'], 'msup'), (namespaces['mathml'], 'mtable'), (namespaces['mathml'], 'mtd'), (namespaces['mathml'], 'mtext'), (namespaces['mathml'], 'mtr'), (namespaces['mathml'], 'munder'), (namespaces['mathml'], 'munderover'), (namespaces['mathml'], 'none'), (namespaces['svg'], 'a'), (namespaces['svg'], 'animate'), (namespaces['svg'], 'animateColor'), (namespaces['svg'], 'animateMotion'), (namespaces['svg'], 'animateTransform'), (namespaces['svg'], 'clipPath'), (namespaces['svg'], 'circle'), (namespaces['svg'], 'defs'), (namespaces['svg'], 'desc'), (namespaces['svg'], 'ellipse'), (namespaces['svg'], 'font-face'), (namespaces['svg'], 'font-face-name'), (namespaces['svg'], 'font-face-src'), (namespaces['svg'], 'g'), (namespaces['svg'], 'glyph'), (namespaces['svg'], 'hkern'), (namespaces['svg'], 'linearGradient'), (namespaces['svg'], 'line'), (namespaces['svg'], 'marker'), (namespaces['svg'], 'metadata'), (namespaces['svg'], 'missing-glyph'), (namespaces['svg'], 'mpath'), (namespaces['svg'], 'path'), (namespaces['svg'], 'polygon'), (namespaces['svg'], 'polyline'), (namespaces['svg'], 'radialGradient'), (namespaces['svg'], 'rect'), (namespaces['svg'], 'set'), (namespaces['svg'], 'stop'), (namespaces['svg'], 'svg'), (namespaces['svg'], 'switch'), (namespaces['svg'], 'text'), (namespaces['svg'], 'title'), (namespaces['svg'], 'tspan'), (namespaces['svg'], 'use'), )) allowed_attributes = frozenset(( # HTML attributes (None, 'abbr'), (None, 'accept'), (None, 'accept-charset'), (None, 'accesskey'), (None, 'action'), (None, 'align'), (None, 'alt'), (None, 'autocomplete'), (None, 'autofocus'), (None, 'axis'), (None, 'background'), (None, 'balance'), (None, 'bgcolor'), (None, 'bgproperties'), (None, 'border'), (None, 'bordercolor'), (None, 'bordercolordark'), (None, 'bordercolorlight'), (None, 'bottompadding'), (None, 'cellpadding'), (None, 'cellspacing'), (None, 'ch'), (None, 'challenge'), (None, 'char'), (None, 'charoff'), (None, 'choff'), (None, 'charset'), (None, 'checked'), (None, 'cite'), (None, 'class'), (None, 'clear'), (None, 'color'), (None, 'cols'), (None, 'colspan'), (None, 'compact'), (None, 'contenteditable'), (None, 'controls'), (None, 'coords'), (None, 'data'), (None, 'datafld'), (None, 'datapagesize'), (None, 'datasrc'), (None, 'datetime'), (None, 'default'), (None, 'delay'), (None, 'dir'), (None, 'disabled'), (None, 'draggable'), (None, 'dynsrc'), (None, 'enctype'), (None, 'end'), (None, 'face'), (None, 'for'), (None, 'form'), (None, 'frame'), (None, 'galleryimg'), (None, 'gutter'), (None, 'headers'), (None, 'height'), (None, 'hidefocus'), (None, 'hidden'), (None, 'high'), (None, 'href'), (None, 'hreflang'), (None, 'hspace'), (None, 'icon'), (None, 'id'), (None, 'inputmode'), (None, 'ismap'), (None, 'keytype'), (None, 'label'), (None, 'leftspacing'), (None, 'lang'), (None, 'list'), (None, 'longdesc'), (None, 'loop'), (None, 'loopcount'), (None, 'loopend'), (None, 'loopstart'), (None, 'low'), (None, 'lowsrc'), (None, 'max'), (None, 'maxlength'), (None, 'media'), (None, 'method'), (None, 'min'), (None, 'multiple'), (None, 'name'), (None, 'nohref'), (None, 'noshade'), (None, 'nowrap'), (None, 'open'), (None, 'optimum'), (None, 'pattern'), (None, 'ping'), (None, 'point-size'), (None, 'poster'), (None, 'pqg'), (None, 'preload'), (None, 'prompt'), (None, 'radiogroup'), (None, 'readonly'), (None, 'rel'), (None, 'repeat-max'), (None, 'repeat-min'), (None, 'replace'), (None, 'required'), (None, 'rev'), (None, 'rightspacing'), (None, 'rows'), (None, 'rowspan'), (None, 'rules'), (None, 'scope'), (None, 'selected'), (None, 'shape'), (None, 'size'), (None, 'span'), (None, 'src'), (None, 'start'), (None, 'step'), (None, 'style'), (None, 'summary'), (None, 'suppress'), (None, 'tabindex'), (None, 'target'), (None, 'template'), (None, 'title'), (None, 'toppadding'), (None, 'type'), (None, 'unselectable'), (None, 'usemap'), (None, 'urn'), (None, 'valign'), (None, 'value'), (None, 'variable'), (None, 'volume'), (None, 'vspace'), (None, 'vrml'), (None, 'width'), (None, 'wrap'), (namespaces['xml'], 'lang'), # MathML attributes (None, 'actiontype'), (None, 'align'), (None, 'columnalign'), (None, 'columnalign'), (None, 'columnalign'), (None, 'columnlines'), (None, 'columnspacing'), (None, 'columnspan'), (None, 'depth'), (None, 'display'), (None, 'displaystyle'), (None, 'equalcolumns'), (None, 'equalrows'), (None, 'fence'), (None, 'fontstyle'), (None, 'fontweight'), (None, 'frame'), (None, 'height'), (None, 'linethickness'), (None, 'lspace'), (None, 'mathbackground'), (None, 'mathcolor'), (None, 'mathvariant'), (None, 'mathvariant'), (None, 'maxsize'), (None, 'minsize'), (None, 'other'), (None, 'rowalign'), (None, 'rowalign'), (None, 'rowalign'), (None, 'rowlines'), (None, 'rowspacing'), (None, 'rowspan'), (None, 'rspace'), (None, 'scriptlevel'), (None, 'selection'), (None, 'separator'), (None, 'stretchy'), (None, 'width'), (None, 'width'), (namespaces['xlink'], 'href'), (namespaces['xlink'], 'show'), (namespaces['xlink'], 'type'), # SVG attributes (None, 'accent-height'), (None, 'accumulate'), (None, 'additive'), (None, 'alphabetic'), (None, 'arabic-form'), (None, 'ascent'), (None, 'attributeName'), (None, 'attributeType'), (None, 'baseProfile'), (None, 'bbox'), (None, 'begin'), (None, 'by'), (None, 'calcMode'), (None, 'cap-height'), (None, 'class'), (None, 'clip-path'), (None, 'color'), (None, 'color-rendering'), (None, 'content'), (None, 'cx'), (None, 'cy'), (None, 'd'), (None, 'dx'), (None, 'dy'), (None, 'descent'), (None, 'display'), (None, 'dur'), (None, 'end'), (None, 'fill'), (None, 'fill-opacity'), (None, 'fill-rule'), (None, 'font-family'), (None, 'font-size'), (None, 'font-stretch'), (None, 'font-style'), (None, 'font-variant'), (None, 'font-weight'), (None, 'from'), (None, 'fx'), (None, 'fy'), (None, 'g1'), (None, 'g2'), (None, 'glyph-name'), (None, 'gradientUnits'), (None, 'hanging'), (None, 'height'), (None, 'horiz-adv-x'), (None, 'horiz-origin-x'), (None, 'id'), (None, 'ideographic'), (None, 'k'), (None, 'keyPoints'), (None, 'keySplines'), (None, 'keyTimes'), (None, 'lang'), (None, 'marker-end'), (None, 'marker-mid'), (None, 'marker-start'), (None, 'markerHeight'), (None, 'markerUnits'), (None, 'markerWidth'), (None, 'mathematical'), (None, 'max'), (None, 'min'), (None, 'name'), (None, 'offset'), (None, 'opacity'), (None, 'orient'), (None, 'origin'), (None, 'overline-position'), (None, 'overline-thickness'), (None, 'panose-1'), (None, 'path'), (None, 'pathLength'), (None, 'points'), (None, 'preserveAspectRatio'), (None, 'r'), (None, 'refX'), (None, 'refY'), (None, 'repeatCount'), (None, 'repeatDur'), (None, 'requiredExtensions'), (None, 'requiredFeatures'), (None, 'restart'), (None, 'rotate'), (None, 'rx'), (None, 'ry'), (None, 'slope'), (None, 'stemh'), (None, 'stemv'), (None, 'stop-color'), (None, 'stop-opacity'), (None, 'strikethrough-position'), (None, 'strikethrough-thickness'), (None, 'stroke'), (None, 'stroke-dasharray'), (None, 'stroke-dashoffset'), (None, 'stroke-linecap'), (None, 'stroke-linejoin'), (None, 'stroke-miterlimit'), (None, 'stroke-opacity'), (None, 'stroke-width'), (None, 'systemLanguage'), (None, 'target'), (None, 'text-anchor'), (None, 'to'), (None, 'transform'), (None, 'type'), (None, 'u1'), (None, 'u2'), (None, 'underline-position'), (None, 'underline-thickness'), (None, 'unicode'), (None, 'unicode-range'), (None, 'units-per-em'), (None, 'values'), (None, 'version'), (None, 'viewBox'), (None, 'visibility'), (None, 'width'), (None, 'widths'), (None, 'x'), (None, 'x-height'), (None, 'x1'), (None, 'x2'), (namespaces['xlink'], 'actuate'), (namespaces['xlink'], 'arcrole'), (namespaces['xlink'], 'href'), (namespaces['xlink'], 'role'), (namespaces['xlink'], 'show'), (namespaces['xlink'], 'title'), (namespaces['xlink'], 'type'), (namespaces['xml'], 'base'), (namespaces['xml'], 'lang'), (namespaces['xml'], 'space'), (None, 'y'), (None, 'y1'), (None, 'y2'), (None, 'zoomAndPan'), )) attr_val_is_uri = frozenset(( (None, 'href'), (None, 'src'), (None, 'cite'), (None, 'action'), (None, 'longdesc'), (None, 'poster'), (None, 'background'), (None, 'datasrc'), (None, 'dynsrc'), (None, 'lowsrc'), (None, 'ping'), (namespaces['xlink'], 'href'), (namespaces['xml'], 'base'), )) svg_attr_val_allows_ref = frozenset(( (None, 'clip-path'), (None, 'color-profile'), (None, 'cursor'), (None, 'fill'), (None, 'filter'), (None, 'marker'), (None, 'marker-start'), (None, 'marker-mid'), (None, 'marker-end'), (None, 'mask'), (None, 'stroke'), )) svg_allow_local_href = frozenset(( (None, 'altGlyph'), (None, 'animate'), (None, 'animateColor'), (None, 'animateMotion'), (None, 'animateTransform'), (None, 'cursor'), (None, 'feImage'), (None, 'filter'), (None, 'linearGradient'), (None, 'pattern'), (None, 'radialGradient'), (None, 'textpath'), (None, 'tref'), (None, 'set'), (None, 'use') )) allowed_css_properties = frozenset(( 'azimuth', 'background-color', 'border-bottom-color', 'border-collapse', 'border-color', 'border-left-color', 'border-right-color', 'border-top-color', 'clear', 'color', 'cursor', 'direction', 'display', 'elevation', 'float', 'font', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'overflow', 'pause', 'pause-after', 'pause-before', 'pitch', 'pitch-range', 'richness', 'speak', 'speak-header', 'speak-numeral', 'speak-punctuation', 'speech-rate', 'stress', 'text-align', 'text-decoration', 'text-indent', 'unicode-bidi', 'vertical-align', 'voice-family', 'volume', 'white-space', 'width', )) allowed_css_keywords = frozenset(( 'auto', 'aqua', 'black', 'block', 'blue', 'bold', 'both', 'bottom', 'brown', 'center', 'collapse', 'dashed', 'dotted', 'fuchsia', 'gray', 'green', '!important', 'italic', 'left', 'lime', 'maroon', 'medium', 'none', 'navy', 'normal', 'nowrap', 'olive', 'pointer', 'purple', 'red', 'right', 'solid', 'silver', 'teal', 'top', 'transparent', 'underline', 'white', 'yellow', )) allowed_svg_properties = frozenset(( 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width', 'stroke-linecap', 'stroke-linejoin', 'stroke-opacity', )) allowed_protocols = frozenset(( 'ed2k', 'ftp', 'http', 'https', 'irc', 'mailto', 'news', 'gopher', 'nntp', 'telnet', 'webcal', 'xmpp', 'callto', 'feed', 'urn', 'aim', 'rsync', 'tag', 'ssh', 'sftp', 'rtsp', 'afs', 'data', )) allowed_content_types = frozenset(( 'image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp', 'text/plain', )) data_content_type = re.compile(r''' ^ # Match a content type / (?P[-a-zA-Z0-9.]+/[-a-zA-Z0-9.]+) # Match any character set and encoding (?:(?:;charset=(?:[-a-zA-Z0-9]+)(?:;(?:base64))?) |(?:;(?:base64))?(?:;charset=(?:[-a-zA-Z0-9]+))?) # Assume the rest is data ,.* $ ''', re.VERBOSE) class Filter(base.Filter): """ sanitization of XHTML+MathML+SVG and of inline style attributes.""" def __init__(self, source, allowed_elements=allowed_elements, allowed_attributes=allowed_attributes, allowed_css_properties=allowed_css_properties, allowed_css_keywords=allowed_css_keywords, allowed_svg_properties=allowed_svg_properties, allowed_protocols=allowed_protocols, allowed_content_types=allowed_content_types, attr_val_is_uri=attr_val_is_uri, svg_attr_val_allows_ref=svg_attr_val_allows_ref, svg_allow_local_href=svg_allow_local_href): super(Filter, self).__init__(source) self.allowed_elements = allowed_elements self.allowed_attributes = allowed_attributes self.allowed_css_properties = allowed_css_properties self.allowed_css_keywords = allowed_css_keywords self.allowed_svg_properties = allowed_svg_properties self.allowed_protocols = allowed_protocols self.allowed_content_types = allowed_content_types self.attr_val_is_uri = attr_val_is_uri self.svg_attr_val_allows_ref = svg_attr_val_allows_ref self.svg_allow_local_href = svg_allow_local_href def __iter__(self): for token in base.Filter.__iter__(self): token = self.sanitize_token(token) if token: yield token # Sanitize the +html+, escaping all elements not in ALLOWED_ELEMENTS, and # stripping out all # attributes not in ALLOWED_ATTRIBUTES. Style # attributes are parsed, and a restricted set, # specified by # ALLOWED_CSS_PROPERTIES and ALLOWED_CSS_KEYWORDS, are allowed through. # attributes in ATTR_VAL_IS_URI are scanned, and only URI schemes specified # in ALLOWED_PROTOCOLS are allowed. # # sanitize_html('') # => <script> do_nasty_stuff() </script> # sanitize_html('Click here for $100') # => Click here for $100 def sanitize_token(self, token): # accommodate filters which use token_type differently token_type = token["type"] if token_type in ("StartTag", "EndTag", "EmptyTag"): name = token["name"] namespace = token["namespace"] if ((namespace, name) in self.allowed_elements or (namespace is None and (namespaces["html"], name) in self.allowed_elements)): return self.allowed_token(token) else: return self.disallowed_token(token) elif token_type == "Comment": pass else: return token def allowed_token(self, token): if "data" in token: attrs = token["data"] attr_names = set(attrs.keys()) # Remove forbidden attributes for to_remove in (attr_names - self.allowed_attributes): del token["data"][to_remove] attr_names.remove(to_remove) # Remove attributes with disallowed URL values for attr in (attr_names & self.attr_val_is_uri): assert attr in attrs # I don't have a clue where this regexp comes from or why it matches those # characters, nor why we call unescape. I just know it's always been here. # Should you be worried by this comment in a sanitizer? Yes. On the other hand, all # this will do is remove *more* than it otherwise would. val_unescaped = re.sub("[`\x00-\x20\x7f-\xa0\s]+", '', unescape(attrs[attr])).lower() # remove replacement characters from unescaped characters val_unescaped = val_unescaped.replace("\ufffd", "") try: uri = urlparse.urlparse(val_unescaped) except ValueError: uri = None del attrs[attr] if uri and uri.scheme: if uri.scheme not in self.allowed_protocols: del attrs[attr] if uri.scheme == 'data': m = data_content_type.match(uri.path) if not m: del attrs[attr] elif m.group('content_type') not in self.allowed_content_types: del attrs[attr] for attr in self.svg_attr_val_allows_ref: if attr in attrs: attrs[attr] = re.sub(r'url\s*\(\s*[^#\s][^)]+?\)', ' ', unescape(attrs[attr])) if (token["name"] in self.svg_allow_local_href and (namespaces['xlink'], 'href') in attrs and re.search('^\s*[^#\s].*', attrs[(namespaces['xlink'], 'href')])): del attrs[(namespaces['xlink'], 'href')] if (None, 'style') in attrs: attrs[(None, 'style')] = self.sanitize_css(attrs[(None, 'style')]) token["data"] = attrs return token def disallowed_token(self, token): token_type = token["type"] if token_type == "EndTag": token["data"] = "" % token["name"] elif token["data"]: assert token_type in ("StartTag", "EmptyTag") attrs = [] for (ns, name), v in token["data"].items(): attrs.append(' %s="%s"' % (name if ns is None else "%s:%s" % (prefixes[ns], name), escape(v))) token["data"] = "<%s%s>" % (token["name"], ''.join(attrs)) else: token["data"] = "<%s>" % token["name"] if token.get("selfClosing"): token["data"] = token["data"][:-1] + "/>" token["type"] = "Characters" del token["name"] return token def sanitize_css(self, style): # disallow urls style = re.compile('url\s*\(\s*[^\s)]+?\s*\)\s*').sub(' ', style) # gauntlet if not re.match("""^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$""", style): return '' if not re.match("^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$", style): return '' clean = [] for prop, value in re.findall("([-\w]+)\s*:\s*([^:;]*)", style): if not value: continue if prop.lower() in self.allowed_css_properties: clean.append(prop + ': ' + value + ';') elif prop.split('-')[0].lower() in ['background', 'border', 'margin', 'padding']: for keyword in value.split(): if keyword not in self.allowed_css_keywords and \ not re.match("^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$", keyword): # noqa break else: clean.append(prop + ': ' + value + ';') elif prop.lower() in self.allowed_svg_properties: clean.append(prop + ': ' + value + ';') return ' '.join(clean) sanitizer.pyc000064400000062253147205636440007314 0ustar00 abcE@`s2ddlmZmZmZddlZddlmZmZddlm Z ddl m Z ddl mZmZd gZeed d fed d fed d fed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed d fed d!fed d"fed d#fed d$fed d%fed d&fed d'fed d(fed d)fed d*fed d+fed d,fed d-fed d.fed d/fed d0fed d1fed d2fed d3fed d4fed d5fed d6fed d7fed d8fed d9fed d:fed d;fed d<fed d=fed d>fed d?fed d@fed dAfed dBfed dCfed dDfed dEfed dFfed dGfed dHfed dIfed dJfed dKfed dLfed dMfed dNfed dOfed dPfed dQfed dRfed dSfed dTfed dUfed dVfed dWfed dXfed dYfed dZfed d[fed d\fed d]fed d^fed d_fed d`fed dafed dbfed dcfed ddfed defed dffed dgfed dhfed difed djfed dkfed dlfed dmfedndofedndpfedndqfedndrfedndsfedndtfedndufedndvfedndwfedndxfedndyfedndzfednd{fednd|fednd}fednd~fedndfedndfedndfedndfedndfedndfedndfedndfedndfedndfedndfedd feddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddffZed4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddded1dfddddddddddddddddddddddddddddddddddddddddedOdfedOdPfedOd%fdddddddddddddddddddddddddddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddedOdfedOdfedOdfedOdfedOdPfedOdfedOd%fed1dfed1dfed1dfdedfdgdhfCZedidjdkdldmdndodpdqdrdsedOdfed1dff Zedtdudvdwdxdydzd{d|d}d~f ZedddddddddddddddfZedZedZedZedZedZejd1ejZd2e j fd3YZ dS(i(tabsolute_importtdivisiontunicode_literalsN(tescapetunescape(t urllib_parsei(tbasei(t namespacestprefixesuFilteruhtmluauabbruacronymuaddressuareauarticleuasideuaudioububigu blockquoteubrubuttonucanvasucaptionucenteruciteucodeucolucolgroupucommandudatagridudatalistuddudeludetailsudfnudialogudirudivudludtuemu event-sourceufieldsetu figcaptionufigureufooterufontuformuheaderuh1uh2uh3uh4uh5uh6uhruiuimguinputuinsukeygenukbdulabelulegenduliumumapumenuumeterumulticolunavunextiduoluoutputuoptgroupuoptionupupreuprogressuqususampusectionuselectusmallusoundusourceuspaceruspanustrikeustrongusubusuputableutbodyutdutextareautimeutfootuthutheadutruttuuuuluvaruvideoumathmlumactionumathumerrorumfracumiu mmultiscriptsumnumoumoverumpaddedumphantomu mprescriptsumrootumrowumspaceumsqrtumstyleumsubumsubsupumsupumtableumtdumtextumtrumunderu munderoverunoneusvguanimateu animateColoru animateMotionuanimateTransformuclipPathucircleudefsudescuellipseu font-faceufont-face-nameu font-face-srcuguglyphuhkernulinearGradientulineumarkerumetadatau missing-glyphumpathupathupolygonupolylineuradialGradienturectusetustopuswitchutextutitleutspanuuseuacceptuaccept-charsetu accesskeyuactionualignualtu autocompleteu autofocusuaxisu backgroundubalanceubgcoloru bgpropertiesuborderu bordercolorubordercolordarkubordercolorlightu bottompaddingu cellpaddingu cellspacinguchu challengeucharucharoffuchoffucharsetucheckeduclassuclearucolorucolsucolspanucompactucontenteditableucontrolsucoordsudataudatafldu datapagesizeudatasrcudatetimeudefaultudelayudisabledu draggableudynsrcuenctypeuendufaceuforuframeu galleryimgugutteruheadersuheightu hidefocusuhiddenuhighuhrefuhreflanguhspaceuiconuidu inputmodeuismapukeytypeu leftspacingulangulistulongdesculoopu loopcountuloopendu loopstartulowulowsrcumaxu maxlengthumediaumethoduminumultipleunameunohrefunoshadeunowrapuopenuoptimumupatternupingu point-sizeuposterupqgupreloadupromptu radiogroupureadonlyurelu repeat-maxu repeat-minureplaceurequiredurevu rightspacingurowsurowspanurulesuscopeuselectedushapeusizeusrcustartustepustyleusummaryusuppressutabindexutargetutemplateu toppaddingutypeu unselectableuusemapuurnuvalignuvalueuvariableuvolumeuvspaceuvrmluwidthuwrapuxmlu actiontypeu columnalignu columnlinesu columnspacingu columnspanudepthudisplayu displaystyleu equalcolumnsu equalrowsufenceu fontstyleu fontweightu linethicknessulspaceumathbackgroundu mathcoloru mathvariantumaxsizeuminsizeuotherurowalignurowlinesu rowspacingurspaceu scriptlevelu selectionu separatorustretchyuxlinkushowu accent-heightu accumulateuadditiveu alphabeticu arabic-formuascentu attributeNameu attributeTypeu baseProfileubboxubeginubyucalcModeu cap-heightu clip-pathucolor-renderingucontentucxucyududxudyudescentudurufillu fill-opacityu fill-ruleu font-familyu font-sizeu font-stretchu font-styleu font-variantu font-weightufromufxufyug1ug2u glyph-nameu gradientUnitsuhangingu horiz-adv-xuhoriz-origin-xu ideographicuku keyPointsu keySplinesukeyTimesu marker-endu marker-midu marker-startu markerHeightu markerUnitsu markerWidthu mathematicaluoffsetuopacityuorientuoriginuoverline-positionuoverline-thicknessupanose-1u pathLengthupointsupreserveAspectRatioururefXurefYu repeatCountu repeatDururequiredExtensionsurequiredFeaturesurestarturotateurxuryuslopeustemhustemvu stop-coloru stop-opacityustrikethrough-positionustrikethrough-thicknessustrokeustroke-dasharrayustroke-dashoffsetustroke-linecapustroke-linejoinustroke-miterlimitustroke-opacityu stroke-widthusystemLanguageu text-anchorutou transformuu1uu2uunderline-positionuunderline-thicknessuunicodeu unicode-rangeu units-per-emuvaluesuversionuviewBoxu visibilityuwidthsuxux-heightux1ux2uactuateuarcroleuroleubaseuspaceuyuy1uy2u zoomAndPanu color-profileucursorufilterumaskualtGlyphufeImageutextpathutrefuazimuthubackground-coloruborder-bottom-coloruborder-collapseu border-coloruborder-left-coloruborder-right-coloruborder-top-coloru directionu elevationufloatuletter-spacingu line-heightuoverflowupauseu pause-afteru pause-beforeupitchu pitch-rangeurichnessuspeaku speak-headeru speak-numeraluspeak-punctuationu speech-rateustressu text-alignutext-decorationu text-indentu unicode-bidiuvertical-alignu voice-familyu white-spaceuautouaquaublackublockublueuboldubothubottomubrownucollapseudashedudottedufuchsiaugrayugreenu !importantuitaliculeftulimeumaroonumediumunavyunormaluoliveupointerupurpleuredurightusolidusilverutealutopu transparentu underlineuwhiteuyellowued2kuftpuhttpuhttpsuircumailtounewsugopherunntputelnetuwebcaluxmppucalltoufeeduaimursyncutagusshusftpurtspuafsu image/pngu image/jpegu image/gifu image/webpu image/bmpu text/plainuL ^ # Match a content type / (?P[-a-zA-Z0-9.]+/[-a-zA-Z0-9.]+) # Match any character set and encoding (?:(?:;charset=(?:[-a-zA-Z0-9]+)(?:;(?:base64))?) |(?:;(?:base64))?(?:;charset=(?:[-a-zA-Z0-9]+))?) # Assume the rest is data ,.* $ tFilterc B`sbeZdZeeeeeee e e e d Z dZdZdZdZdZRS(uA sanitization of XHTML+MathML+SVG and of inline style attributes.c C`sttt|j|||_||_||_||_||_||_||_ | |_ | |_ | |_ dS(N( tsuperR t__init__tallowed_elementstallowed_attributestallowed_css_propertiestallowed_css_keywordstallowed_svg_propertiestallowed_protocolstallowed_content_typestattr_val_is_uritsvg_attr_val_allows_reftsvg_allow_local_href( tselftsourceR R RRRRRRRR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR s          cc`s>x7tjj|D]#}|j|}|r|VqqWdS(N(RR t__iter__tsanitize_token(Rttoken((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyRscC`s|d}|d kr|d}|d}||f|jksd|dkrqtd|f|jkrq|j|S|j|Sn|dkrn|SdS( NutypeuStartTaguEndTaguEmptyTagunameu namespaceuhtmluComment(uStartTaguEndTaguEmptyTag(R tNoneRt allowed_tokentdisallowed_token(RRt token_typetnamet namespace((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyRs       c C`sKd|krG|d}t|j}x-||jD]}|d|=|j|q6Wx||j@D]}||ks~ttjddt||j }|j dd}yt j |}Wnt k rd}||=nX|rf|jrf|j|jkr||=n|jdkrmtj|j}|sE||=qj|jd|jkrj||=qjqmqfqfWxC|jD]8}||kr{tjddt||||unameudatauStartTaguEmptyTagu %s="%s"u%s:%su<%s%s>uu<%s>u selfClosingiu/>u Characters(uStartTaguEmptyTag(R$titemstappendRRRtjointget(RRRR2tnsRtv((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR2s   #A$ cC`sctjdjd|}tjd|s1dStjd|sGdSg}xtjd|D]\}}|sxq`n|j|jkr|j|d|dq`|jd d jdkr!x|jD],}||j krtjd| rPqqW|j|d|dq`|j|j kr`|j|d|dq`q`Wdj |S(Nuurl\s*\(\s*[^\s)]+?\s*\)\s*u u@^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$uu ^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$u([-\w]+)\s*:\s*([^:;]*)u: u;u-iu backgrounduborderumarginupaddingu\^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$(u backgrounduborderumarginupadding( R%tcompileR&R-tfindallR'RR:tsplitRRR;(Rtstyletcleantproptvaluetkeyword((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR1Fs*  (t__name__t __module__t__doc__R R RRRRRRRRR RRRRR1(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR s    2 (Nuabbr(Nuaccept(Nuaccept-charset(Nu accesskey(Nuaction(Nualign(Nualt(Nu autocomplete(Nu autofocus(Nuaxis(Nu background(Nubalance(Nubgcolor(Nu bgproperties(Nuborder(Nu bordercolor(Nubordercolordark(Nubordercolorlight(Nu bottompadding(Nu cellpadding(Nu cellspacing(Nuch(Nu challenge(Nuchar(Nucharoff(Nuchoff(Nucharset(Nuchecked(Nucite(Nuclass(Nuclear(Nucolor(Nucols(Nucolspan(Nucompact(Nucontenteditable(Nucontrols(Nucoords(Nudata(Nudatafld(Nu datapagesize(Nudatasrc(Nudatetime(Nudefault(Nudelay(Nudir(Nudisabled(Nu draggable(Nudynsrc(Nuenctype(Nuend(Nuface(Nufor(Nuform(Nuframe(Nu galleryimg(Nugutter(Nuheaders(Nuheight(Nu hidefocus(Nuhidden(Nuhigh(Nuhref(Nuhreflang(Nuhspace(Nuicon(Nuid(Nu inputmode(Nuismap(Nukeytype(Nulabel(Nu leftspacing(Nulang(Nulist(Nulongdesc(Nuloop(Nu loopcount(Nuloopend(Nu loopstart(Nulow(Nulowsrc(Numax(Nu maxlength(Numedia(Numethod(Numin(Numultiple(Nuname(Nunohref(Nunoshade(Nunowrap(Nuopen(Nuoptimum(Nupattern(Nuping(Nu point-size(Nuposter(Nupqg(Nupreload(Nuprompt(Nu radiogroup(Nureadonly(Nurel(Nu repeat-max(Nu repeat-min(Nureplace(Nurequired(Nurev(Nu rightspacing(Nurows(Nurowspan(Nurules(Nuscope(Nuselected(Nushape(Nusize(Nuspan(Nusrc(Nustart(Nustep(Nustyle(Nusummary(Nusuppress(Nutabindex(Nutarget(Nutemplate(Nutitle(Nu toppadding(Nutype(Nu unselectable(Nuusemap(Nuurn(Nuvalign(Nuvalue(Nuvariable(Nuvolume(Nuvspace(Nuvrml(Nuwidth(Nuwrap(Nu actiontype(Nualign(Nu columnalign(Nu columnalign(Nu columnalign(Nu columnlines(Nu columnspacing(Nu columnspan(Nudepth(Nudisplay(Nu displaystyle(Nu equalcolumns(Nu equalrows(Nufence(Nu fontstyle(Nu fontweight(Nuframe(Nuheight(Nu linethickness(Nulspace(Numathbackground(Nu mathcolor(Nu mathvariant(Nu mathvariant(Numaxsize(Numinsize(Nuother(Nurowalign(Nurowalign(Nurowalign(Nurowlines(Nu rowspacing(Nurowspan(Nurspace(Nu scriptlevel(Nu selection(Nu separator(Nustretchy(Nuwidth(Nuwidth(Nu accent-height(Nu accumulate(Nuadditive(Nu alphabetic(Nu arabic-form(Nuascent(Nu attributeName(Nu attributeType(Nu baseProfile(Nubbox(Nubegin(Nuby(NucalcMode(Nu cap-height(Nuclass(Nu clip-path(Nucolor(Nucolor-rendering(Nucontent(Nucx(Nucy(Nud(Nudx(Nudy(Nudescent(Nudisplay(Nudur(Nuend(Nufill(Nu fill-opacity(Nu fill-rule(Nu font-family(Nu font-size(Nu font-stretch(Nu font-style(Nu font-variant(Nu font-weight(Nufrom(Nufx(Nufy(Nug1(Nug2(Nu glyph-name(Nu gradientUnits(Nuhanging(Nuheight(Nu horiz-adv-x(Nuhoriz-origin-x(Nuid(Nu ideographic(Nuk(Nu keyPoints(Nu keySplines(NukeyTimes(Nulang(Nu marker-end(Nu marker-mid(Nu marker-start(Nu markerHeight(Nu markerUnits(Nu markerWidth(Nu mathematical(Numax(Numin(Nuname(Nuoffset(Nuopacity(Nuorient(Nuorigin(Nuoverline-position(Nuoverline-thickness(Nupanose-1(Nupath(Nu pathLength(Nupoints(NupreserveAspectRatio(Nur(NurefX(NurefY(Nu repeatCount(Nu repeatDur(NurequiredExtensions(NurequiredFeatures(Nurestart(Nurotate(Nurx(Nury(Nuslope(Nustemh(Nustemv(Nu stop-color(Nu stop-opacity(Nustrikethrough-position(Nustrikethrough-thickness(Nustroke(Nustroke-dasharray(Nustroke-dashoffset(Nustroke-linecap(Nustroke-linejoin(Nustroke-miterlimit(Nustroke-opacity(Nu stroke-width(NusystemLanguage(Nutarget(Nu text-anchor(Nuto(Nu transform(Nutype(Nuu1(Nuu2(Nuunderline-position(Nuunderline-thickness(Nuunicode(Nu unicode-range(Nu units-per-em(Nuvalues(Nuversion(NuviewBox(Nu visibility(Nuwidth(Nuwidths(Nux(Nux-height(Nux1(Nux2(Nuy(Nuy1(Nuy2(Nu zoomAndPan(Nuhref(Nusrc(Nucite(Nuaction(Nulongdesc(Nuposter(Nu background(Nudatasrc(Nudynsrc(Nulowsrc(Nuping(Nu clip-path(Nu color-profile(Nucursor(Nufill(Nufilter(Numarker(Nu marker-start(Nu marker-mid(Nu marker-end(Numask(Nustroke(NualtGlyph(Nuanimate(Nu animateColor(Nu animateMotion(NuanimateTransform(Nucursor(NufeImage(Nufilter(NulinearGradient(Nupattern(NuradialGradient(Nutextpath(Nutref(Nuset(Nuuse(.uazimuthubackground-coloruborder-bottom-coloruborder-collapseu border-coloruborder-left-coloruborder-right-coloruborder-top-coloruclearucolorucursoru directionudisplayu elevationufloatufontu font-familyu font-sizeu font-styleu font-variantu font-weightuheightuletter-spacingu line-heightuoverflowupauseu pause-afteru pause-beforeupitchu pitch-rangeurichnessuspeaku speak-headeru speak-numeraluspeak-punctuationu speech-rateustressu text-alignutext-decorationu text-indentu unicode-bidiuvertical-alignu voice-familyuvolumeu white-spaceuwidth('uautouaquaublackublockublueuboldubothubottomubrownucenterucollapseudashedudottedufuchsiaugrayugreenu !importantuitaliculeftulimeumaroonumediumunoneunavyunormalunowrapuoliveupointerupurpleuredurightusolidusilverutealutopu transparentu underlineuwhiteuyellow(ufillu fill-opacityu fill-ruleustrokeu stroke-widthustroke-linecapustroke-linejoinustroke-opacity(ued2kuftpuhttpuhttpsuircumailtounewsugopherunntputelnetuwebcaluxmppucalltoufeeduurnuaimursyncutagusshusftpurtspuafsudata(u image/pngu image/jpegu image/gifu image/webpu image/bmpu text/plain(!t __future__RRRR%txml.sax.saxutilsRRtpip._vendor.six.movesRR)tRt constantsRRt__all__t frozensetR RR RRRRRRRRR?tVERBOSER,R (((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyts2                                                                                                                                                                                           sanitizer.pyo000064400000062062147205636440007326 0ustar00 abcE@`s2ddlmZmZmZddlZddlmZmZddlm Z ddl m Z ddl mZmZd gZeed d fed d fed d fed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed dfed d fed d!fed d"fed d#fed d$fed d%fed d&fed d'fed d(fed d)fed d*fed d+fed d,fed d-fed d.fed d/fed d0fed d1fed d2fed d3fed d4fed d5fed d6fed d7fed d8fed d9fed d:fed d;fed d<fed d=fed d>fed d?fed d@fed dAfed dBfed dCfed dDfed dEfed dFfed dGfed dHfed dIfed dJfed dKfed dLfed dMfed dNfed dOfed dPfed dQfed dRfed dSfed dTfed dUfed dVfed dWfed dXfed dYfed dZfed d[fed d\fed d]fed d^fed d_fed d`fed dafed dbfed dcfed ddfed defed dffed dgfed dhfed difed djfed dkfed dlfed dmfedndofedndpfedndqfedndrfedndsfedndtfedndufedndvfedndwfedndxfedndyfedndzfednd{fednd|fednd}fednd~fedndfedndfedndfedndfedndfedndfedndfedndfedndfedndfedndfedd feddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddfeddffZed4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddded1dfddddddddddddddddddddddddddddddddddddddddedOdfedOdPfedOd%fdddddddddddddddddddddddddddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddedOdfedOdfedOdfedOdfedOdPfedOdfedOd%fed1dfed1dfed1dfdedfdgdhfCZedidjdkdldmdndodpdqdrdsedOdfed1dff Zedtdudvdwdxdydzd{d|d}d~f ZedddddddddddddddfZedZedZedZedZedZejd1ejZd2e j fd3YZ dS(i(tabsolute_importtdivisiontunicode_literalsN(tescapetunescape(t urllib_parsei(tbasei(t namespacestprefixesuFilteruhtmluauabbruacronymuaddressuareauarticleuasideuaudioububigu blockquoteubrubuttonucanvasucaptionucenteruciteucodeucolucolgroupucommandudatagridudatalistuddudeludetailsudfnudialogudirudivudludtuemu event-sourceufieldsetu figcaptionufigureufooterufontuformuheaderuh1uh2uh3uh4uh5uh6uhruiuimguinputuinsukeygenukbdulabelulegenduliumumapumenuumeterumulticolunavunextiduoluoutputuoptgroupuoptionupupreuprogressuqususampusectionuselectusmallusoundusourceuspaceruspanustrikeustrongusubusuputableutbodyutdutextareautimeutfootuthutheadutruttuuuuluvaruvideoumathmlumactionumathumerrorumfracumiu mmultiscriptsumnumoumoverumpaddedumphantomu mprescriptsumrootumrowumspaceumsqrtumstyleumsubumsubsupumsupumtableumtdumtextumtrumunderu munderoverunoneusvguanimateu animateColoru animateMotionuanimateTransformuclipPathucircleudefsudescuellipseu font-faceufont-face-nameu font-face-srcuguglyphuhkernulinearGradientulineumarkerumetadatau missing-glyphumpathupathupolygonupolylineuradialGradienturectusetustopuswitchutextutitleutspanuuseuacceptuaccept-charsetu accesskeyuactionualignualtu autocompleteu autofocusuaxisu backgroundubalanceubgcoloru bgpropertiesuborderu bordercolorubordercolordarkubordercolorlightu bottompaddingu cellpaddingu cellspacinguchu challengeucharucharoffuchoffucharsetucheckeduclassuclearucolorucolsucolspanucompactucontenteditableucontrolsucoordsudataudatafldu datapagesizeudatasrcudatetimeudefaultudelayudisabledu draggableudynsrcuenctypeuendufaceuforuframeu galleryimgugutteruheadersuheightu hidefocusuhiddenuhighuhrefuhreflanguhspaceuiconuidu inputmodeuismapukeytypeu leftspacingulangulistulongdesculoopu loopcountuloopendu loopstartulowulowsrcumaxu maxlengthumediaumethoduminumultipleunameunohrefunoshadeunowrapuopenuoptimumupatternupingu point-sizeuposterupqgupreloadupromptu radiogroupureadonlyurelu repeat-maxu repeat-minureplaceurequiredurevu rightspacingurowsurowspanurulesuscopeuselectedushapeusizeusrcustartustepustyleusummaryusuppressutabindexutargetutemplateu toppaddingutypeu unselectableuusemapuurnuvalignuvalueuvariableuvolumeuvspaceuvrmluwidthuwrapuxmlu actiontypeu columnalignu columnlinesu columnspacingu columnspanudepthudisplayu displaystyleu equalcolumnsu equalrowsufenceu fontstyleu fontweightu linethicknessulspaceumathbackgroundu mathcoloru mathvariantumaxsizeuminsizeuotherurowalignurowlinesu rowspacingurspaceu scriptlevelu selectionu separatorustretchyuxlinkushowu accent-heightu accumulateuadditiveu alphabeticu arabic-formuascentu attributeNameu attributeTypeu baseProfileubboxubeginubyucalcModeu cap-heightu clip-pathucolor-renderingucontentucxucyududxudyudescentudurufillu fill-opacityu fill-ruleu font-familyu font-sizeu font-stretchu font-styleu font-variantu font-weightufromufxufyug1ug2u glyph-nameu gradientUnitsuhangingu horiz-adv-xuhoriz-origin-xu ideographicuku keyPointsu keySplinesukeyTimesu marker-endu marker-midu marker-startu markerHeightu markerUnitsu markerWidthu mathematicaluoffsetuopacityuorientuoriginuoverline-positionuoverline-thicknessupanose-1u pathLengthupointsupreserveAspectRatioururefXurefYu repeatCountu repeatDururequiredExtensionsurequiredFeaturesurestarturotateurxuryuslopeustemhustemvu stop-coloru stop-opacityustrikethrough-positionustrikethrough-thicknessustrokeustroke-dasharrayustroke-dashoffsetustroke-linecapustroke-linejoinustroke-miterlimitustroke-opacityu stroke-widthusystemLanguageu text-anchorutou transformuu1uu2uunderline-positionuunderline-thicknessuunicodeu unicode-rangeu units-per-emuvaluesuversionuviewBoxu visibilityuwidthsuxux-heightux1ux2uactuateuarcroleuroleubaseuspaceuyuy1uy2u zoomAndPanu color-profileucursorufilterumaskualtGlyphufeImageutextpathutrefuazimuthubackground-coloruborder-bottom-coloruborder-collapseu border-coloruborder-left-coloruborder-right-coloruborder-top-coloru directionu elevationufloatuletter-spacingu line-heightuoverflowupauseu pause-afteru pause-beforeupitchu pitch-rangeurichnessuspeaku speak-headeru speak-numeraluspeak-punctuationu speech-rateustressu text-alignutext-decorationu text-indentu unicode-bidiuvertical-alignu voice-familyu white-spaceuautouaquaublackublockublueuboldubothubottomubrownucollapseudashedudottedufuchsiaugrayugreenu !importantuitaliculeftulimeumaroonumediumunavyunormaluoliveupointerupurpleuredurightusolidusilverutealutopu transparentu underlineuwhiteuyellowued2kuftpuhttpuhttpsuircumailtounewsugopherunntputelnetuwebcaluxmppucalltoufeeduaimursyncutagusshusftpurtspuafsu image/pngu image/jpegu image/gifu image/webpu image/bmpu text/plainuL ^ # Match a content type / (?P[-a-zA-Z0-9.]+/[-a-zA-Z0-9.]+) # Match any character set and encoding (?:(?:;charset=(?:[-a-zA-Z0-9]+)(?:;(?:base64))?) |(?:;(?:base64))?(?:;charset=(?:[-a-zA-Z0-9]+))?) # Assume the rest is data ,.* $ tFilterc B`sbeZdZeeeeeee e e e d Z dZdZdZdZdZRS(uA sanitization of XHTML+MathML+SVG and of inline style attributes.c C`sttt|j|||_||_||_||_||_||_||_ | |_ | |_ | |_ dS(N( tsuperR t__init__tallowed_elementstallowed_attributestallowed_css_propertiestallowed_css_keywordstallowed_svg_propertiestallowed_protocolstallowed_content_typestattr_val_is_uritsvg_attr_val_allows_reftsvg_allow_local_href( tselftsourceR R RRRRRRRR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR s          cc`s>x7tjj|D]#}|j|}|r|VqqWdS(N(RR t__iter__tsanitize_token(Rttoken((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyRscC`s|d}|d kr|d}|d}||f|jksd|dkrqtd|f|jkrq|j|S|j|Sn|dkrn|SdS( NutypeuStartTaguEndTaguEmptyTagunameu namespaceuhtmluComment(uStartTaguEndTaguEmptyTag(R tNoneRt allowed_tokentdisallowed_token(RRt token_typetnamet namespace((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyRs       c C`s9d|kr5|d}t|j}x-||jD]}|d|=|j|q6Wx||j@D]}tjddt||j}|j dd}yt j |}Wnt k rd}||=nX|rf|j rf|j |jkr||=n|j dkr[tj|j}|s3||=qX|jd|jkrX||=qXq[qfqfWxC|jD]8}||kritjddt||||unameudatau %s="%s"u%s:%su<%s%s>uu<%s>u selfClosingiu/>u Characters(titemstappendRRRtjointget(RRRR1tnsRtv((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR2s   #A$ cC`sctjdjd|}tjd|s1dStjd|sGdSg}xtjd|D]\}}|sxq`n|j|jkr|j|d|dq`|jd d jdkr!x|jD],}||j krtjd| rPqqW|j|d|dq`|j|j kr`|j|d|dq`q`Wdj |S(Nuurl\s*\(\s*[^\s)]+?\s*\)\s*u u@^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$uu ^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$u([-\w]+)\s*:\s*([^:;]*)u: u;u-iu backgrounduborderumarginupaddingu\^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$(u backgrounduborderumarginupadding( R$tcompileR%R,tfindallR&RR9tsplitRRR:(Rtstyletcleantproptvaluetkeyword((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR0Fs*  (t__name__t __module__t__doc__R R RRRRRRRRR RRRRR0(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyR s    2 (Nuabbr(Nuaccept(Nuaccept-charset(Nu accesskey(Nuaction(Nualign(Nualt(Nu autocomplete(Nu autofocus(Nuaxis(Nu background(Nubalance(Nubgcolor(Nu bgproperties(Nuborder(Nu bordercolor(Nubordercolordark(Nubordercolorlight(Nu bottompadding(Nu cellpadding(Nu cellspacing(Nuch(Nu challenge(Nuchar(Nucharoff(Nuchoff(Nucharset(Nuchecked(Nucite(Nuclass(Nuclear(Nucolor(Nucols(Nucolspan(Nucompact(Nucontenteditable(Nucontrols(Nucoords(Nudata(Nudatafld(Nu datapagesize(Nudatasrc(Nudatetime(Nudefault(Nudelay(Nudir(Nudisabled(Nu draggable(Nudynsrc(Nuenctype(Nuend(Nuface(Nufor(Nuform(Nuframe(Nu galleryimg(Nugutter(Nuheaders(Nuheight(Nu hidefocus(Nuhidden(Nuhigh(Nuhref(Nuhreflang(Nuhspace(Nuicon(Nuid(Nu inputmode(Nuismap(Nukeytype(Nulabel(Nu leftspacing(Nulang(Nulist(Nulongdesc(Nuloop(Nu loopcount(Nuloopend(Nu loopstart(Nulow(Nulowsrc(Numax(Nu maxlength(Numedia(Numethod(Numin(Numultiple(Nuname(Nunohref(Nunoshade(Nunowrap(Nuopen(Nuoptimum(Nupattern(Nuping(Nu point-size(Nuposter(Nupqg(Nupreload(Nuprompt(Nu radiogroup(Nureadonly(Nurel(Nu repeat-max(Nu repeat-min(Nureplace(Nurequired(Nurev(Nu rightspacing(Nurows(Nurowspan(Nurules(Nuscope(Nuselected(Nushape(Nusize(Nuspan(Nusrc(Nustart(Nustep(Nustyle(Nusummary(Nusuppress(Nutabindex(Nutarget(Nutemplate(Nutitle(Nu toppadding(Nutype(Nu unselectable(Nuusemap(Nuurn(Nuvalign(Nuvalue(Nuvariable(Nuvolume(Nuvspace(Nuvrml(Nuwidth(Nuwrap(Nu actiontype(Nualign(Nu columnalign(Nu columnalign(Nu columnalign(Nu columnlines(Nu columnspacing(Nu columnspan(Nudepth(Nudisplay(Nu displaystyle(Nu equalcolumns(Nu equalrows(Nufence(Nu fontstyle(Nu fontweight(Nuframe(Nuheight(Nu linethickness(Nulspace(Numathbackground(Nu mathcolor(Nu mathvariant(Nu mathvariant(Numaxsize(Numinsize(Nuother(Nurowalign(Nurowalign(Nurowalign(Nurowlines(Nu rowspacing(Nurowspan(Nurspace(Nu scriptlevel(Nu selection(Nu separator(Nustretchy(Nuwidth(Nuwidth(Nu accent-height(Nu accumulate(Nuadditive(Nu alphabetic(Nu arabic-form(Nuascent(Nu attributeName(Nu attributeType(Nu baseProfile(Nubbox(Nubegin(Nuby(NucalcMode(Nu cap-height(Nuclass(Nu clip-path(Nucolor(Nucolor-rendering(Nucontent(Nucx(Nucy(Nud(Nudx(Nudy(Nudescent(Nudisplay(Nudur(Nuend(Nufill(Nu fill-opacity(Nu fill-rule(Nu font-family(Nu font-size(Nu font-stretch(Nu font-style(Nu font-variant(Nu font-weight(Nufrom(Nufx(Nufy(Nug1(Nug2(Nu glyph-name(Nu gradientUnits(Nuhanging(Nuheight(Nu horiz-adv-x(Nuhoriz-origin-x(Nuid(Nu ideographic(Nuk(Nu keyPoints(Nu keySplines(NukeyTimes(Nulang(Nu marker-end(Nu marker-mid(Nu marker-start(Nu markerHeight(Nu markerUnits(Nu markerWidth(Nu mathematical(Numax(Numin(Nuname(Nuoffset(Nuopacity(Nuorient(Nuorigin(Nuoverline-position(Nuoverline-thickness(Nupanose-1(Nupath(Nu pathLength(Nupoints(NupreserveAspectRatio(Nur(NurefX(NurefY(Nu repeatCount(Nu repeatDur(NurequiredExtensions(NurequiredFeatures(Nurestart(Nurotate(Nurx(Nury(Nuslope(Nustemh(Nustemv(Nu stop-color(Nu stop-opacity(Nustrikethrough-position(Nustrikethrough-thickness(Nustroke(Nustroke-dasharray(Nustroke-dashoffset(Nustroke-linecap(Nustroke-linejoin(Nustroke-miterlimit(Nustroke-opacity(Nu stroke-width(NusystemLanguage(Nutarget(Nu text-anchor(Nuto(Nu transform(Nutype(Nuu1(Nuu2(Nuunderline-position(Nuunderline-thickness(Nuunicode(Nu unicode-range(Nu units-per-em(Nuvalues(Nuversion(NuviewBox(Nu visibility(Nuwidth(Nuwidths(Nux(Nux-height(Nux1(Nux2(Nuy(Nuy1(Nuy2(Nu zoomAndPan(Nuhref(Nusrc(Nucite(Nuaction(Nulongdesc(Nuposter(Nu background(Nudatasrc(Nudynsrc(Nulowsrc(Nuping(Nu clip-path(Nu color-profile(Nucursor(Nufill(Nufilter(Numarker(Nu marker-start(Nu marker-mid(Nu marker-end(Numask(Nustroke(NualtGlyph(Nuanimate(Nu animateColor(Nu animateMotion(NuanimateTransform(Nucursor(NufeImage(Nufilter(NulinearGradient(Nupattern(NuradialGradient(Nutextpath(Nutref(Nuset(Nuuse(.uazimuthubackground-coloruborder-bottom-coloruborder-collapseu border-coloruborder-left-coloruborder-right-coloruborder-top-coloruclearucolorucursoru directionudisplayu elevationufloatufontu font-familyu font-sizeu font-styleu font-variantu font-weightuheightuletter-spacingu line-heightuoverflowupauseu pause-afteru pause-beforeupitchu pitch-rangeurichnessuspeaku speak-headeru speak-numeraluspeak-punctuationu speech-rateustressu text-alignutext-decorationu text-indentu unicode-bidiuvertical-alignu voice-familyuvolumeu white-spaceuwidth('uautouaquaublackublockublueuboldubothubottomubrownucenterucollapseudashedudottedufuchsiaugrayugreenu !importantuitaliculeftulimeumaroonumediumunoneunavyunormalunowrapuoliveupointerupurpleuredurightusolidusilverutealutopu transparentu underlineuwhiteuyellow(ufillu fill-opacityu fill-ruleustrokeu stroke-widthustroke-linecapustroke-linejoinustroke-opacity(ued2kuftpuhttpuhttpsuircumailtounewsugopherunntputelnetuwebcaluxmppucalltoufeeduurnuaimursyncutagusshusftpurtspuafsudata(u image/pngu image/jpegu image/gifu image/webpu image/bmpu text/plain(!t __future__RRRR$txml.sax.saxutilsRRtpip._vendor.six.movesRR(tRt constantsRRt__all__t frozensetR RR RRRRRRRRR>tVERBOSER+R (((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/sanitizer.pyts2                                                                                                                                                                                           whitespace.py000064400000002163147205636440007267 0ustar00from __future__ import absolute_import, division, unicode_literals import re from . import base from ..constants import rcdataElements, spaceCharacters spaceCharacters = "".join(spaceCharacters) SPACES_REGEX = re.compile("[%s]+" % spaceCharacters) class Filter(base.Filter): spacePreserveElements = frozenset(["pre", "textarea"] + list(rcdataElements)) def __iter__(self): preserve = 0 for token in base.Filter.__iter__(self): type = token["type"] if type == "StartTag" \ and (preserve or token["name"] in self.spacePreserveElements): preserve += 1 elif type == "EndTag" and preserve: preserve -= 1 elif not preserve and type == "SpaceCharacters" and token["data"]: # Test on token["data"] above to not introduce spaces where there were not token["data"] = " " elif not preserve and type == "Characters": token["data"] = collapse_spaces(token["data"]) yield token def collapse_spaces(text): return SPACES_REGEX.sub(' ', text) whitespace.pyc000064400000003177147205636440007440 0ustar00 abc@`sddlmZmZmZddlZddlmZddlmZm Z dj e Z ej de Z d ej fd YZ d ZdS( i(tabsolute_importtdivisiontunicode_literalsNi(tbasei(trcdataElementstspaceCharactersuu[%s]+tFiltercB`s-eZeddgeeZdZRS(upreutextareacc`sd}xtjj|D]}|d}|dkr[|sN|d|jkr[|d7}ns|dkrz|rz|d8}nT| r|dkr|drd |ds whitespace.pyo000064400000003177147205636440007454 0ustar00 abc@`sddlmZmZmZddlZddlmZddlmZm Z dj e Z ej de Z d ej fd YZ d ZdS( i(tabsolute_importtdivisiontunicode_literalsNi(tbasei(trcdataElementstspaceCharactersuu[%s]+tFiltercB`s-eZeddgeeZdZRS(upreutextareacc`sd}xtjj|D]}|d}|dkr[|sN|d|jkr[|d7}ns|dkrz|rz|d8}nT| r|dkr|drd |ds