mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Update bleach stubs (#5631)
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
"stdlib/xml/sax",
|
||||
"stubs/backports",
|
||||
"stubs/backports_abc",
|
||||
"stubs/bleach",
|
||||
"stubs/boto",
|
||||
"stubs/cryptography",
|
||||
"stubs/docutils",
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
bleach.linkifier.LinkifyFilter.__init__
|
||||
bleach.sanitizer.BleachSanitizerFilter.__init__
|
||||
bleach.html5lib_shim.*
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = "0.1"
|
||||
version = "3.3"
|
||||
python2 = true
|
||||
|
||||
@@ -7,8 +7,11 @@ from bleach.sanitizer import (
|
||||
ALLOWED_STYLES as ALLOWED_STYLES,
|
||||
ALLOWED_TAGS as ALLOWED_TAGS,
|
||||
Cleaner as Cleaner,
|
||||
_Attributes,
|
||||
)
|
||||
|
||||
__all__ = ["clean", "linkify"]
|
||||
|
||||
__releasedate__: Text
|
||||
__version__: Text
|
||||
VERSION: Any # packaging.version.Version
|
||||
@@ -16,7 +19,7 @@ VERSION: Any # packaging.version.Version
|
||||
def clean(
|
||||
text: Text,
|
||||
tags: Container[Text] = ...,
|
||||
attributes: Any = ...,
|
||||
attributes: _Attributes = ...,
|
||||
styles: Container[Text] = ...,
|
||||
protocols: Container[Text] = ...,
|
||||
strip: bool = ...,
|
||||
|
||||
26
stubs/bleach/bleach/html5lib_shim.pyi
Normal file
26
stubs/bleach/bleach/html5lib_shim.pyi
Normal file
@@ -0,0 +1,26 @@
|
||||
from typing import Any, Generator, Iterable, List, Optional, Text
|
||||
|
||||
class HTMLParser(object): # actually html5lib.HTMLParser
|
||||
def __getattr__(self, __name: Text) -> Any: ... # incomplete
|
||||
|
||||
class Filter(object): # actually html5lib.filters.base.Filter
|
||||
def __getattr__(self, __name: Text) -> Any: ... # incomplete
|
||||
|
||||
class SanitizerFilter(object): # actually html5lib.filters.sanitizer.Filter
|
||||
def __getattr__(self, __name: Text) -> Any: ... # incomplete
|
||||
|
||||
class HTMLSerializer(object): # actually html5lib.serializer.HTMLSerializer
|
||||
def __getattr__(self, __name: Text) -> Any: ... # incomplete
|
||||
|
||||
class BleachHTMLParser(HTMLParser):
|
||||
tags: Optional[List[Text]]
|
||||
strip: bool
|
||||
consume_entities: bool
|
||||
def __init__(self, tags: Optional[Iterable[Text]], strip: bool, consume_entities: bool, **kwargs) -> None: ...
|
||||
|
||||
class BleachHTMLSerializer(HTMLSerializer):
|
||||
escape_rcdata: bool
|
||||
def escape_base_amp(self, stoken: Text) -> Generator[Text, None, None]: ...
|
||||
def serialize(self, treewalker, encoding: Optional[Text] = ...) -> Generator[Text, None, None]: ...
|
||||
|
||||
def __getattr__(__name: Text) -> Any: ... # incomplete
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Any, Container, Iterable, List, MutableMapping, Optional, Pattern, Protocol, Text
|
||||
|
||||
from .html5lib_shim import Filter
|
||||
|
||||
_Attrs = MutableMapping[Any, Text]
|
||||
|
||||
class _Callback(Protocol):
|
||||
@@ -13,6 +15,9 @@ def build_url_re(tlds: Iterable[Text] = ..., protocols: Iterable[Text] = ...) ->
|
||||
|
||||
URL_RE: Pattern[Text]
|
||||
PROTO_RE: Pattern[Text]
|
||||
|
||||
def build_email_re(tlds: Iterable[Text] = ...) -> Pattern[Text]: ...
|
||||
|
||||
EMAIL_RE: Pattern[Text]
|
||||
|
||||
class Linker(object):
|
||||
@@ -27,5 +32,13 @@ class Linker(object):
|
||||
) -> None: ...
|
||||
def linkify(self, text: Text) -> Text: ...
|
||||
|
||||
class LinkifyFilter(object): # TODO: derives from html5lib.Filter
|
||||
def __getattr__(self, item: str) -> Any: ... # incomplete
|
||||
class LinkifyFilter(Filter):
|
||||
callbacks: Any
|
||||
skip_tags: Container[Text]
|
||||
parse_email: bool
|
||||
url_re: Any
|
||||
email_re: Any
|
||||
def __init__(
|
||||
self, source, callbacks=..., skip_tags: Container[Text] | None = ..., parse_email: bool = ..., url_re=..., email_re=...
|
||||
) -> None: ...
|
||||
def __getattr__(self, item: Text) -> Any: ... # incomplete
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Any, Callable, Container, Dict, Iterable, List, Optional, Pattern, Text, Union
|
||||
|
||||
from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter
|
||||
|
||||
ALLOWED_TAGS: List[Text]
|
||||
ALLOWED_ATTRIBUTES: Dict[Text, List[Text]]
|
||||
ALLOWED_STYLES: List[Text]
|
||||
@@ -13,10 +15,20 @@ INVISIBLE_REPLACEMENT_CHAR: Text
|
||||
_Filter = Any
|
||||
|
||||
class Cleaner(object):
|
||||
tags: Container[Text]
|
||||
attributes: _Attributes
|
||||
styles: Container[Text]
|
||||
protocols: Container[Text]
|
||||
strip: bool
|
||||
strip_comments: bool
|
||||
filters: Iterable[_Filter]
|
||||
parser: BleachHTMLParser
|
||||
walker: Any
|
||||
serializer: BleachHTMLSerializer
|
||||
def __init__(
|
||||
self,
|
||||
tags: Container[Text] = ...,
|
||||
attributes: Any = ...,
|
||||
attributes: _Attributes = ...,
|
||||
styles: Container[Text] = ...,
|
||||
protocols: Container[Text] = ...,
|
||||
strip: bool = ...,
|
||||
@@ -27,8 +39,28 @@ class Cleaner(object):
|
||||
|
||||
_AttributeFilter = Callable[[Text, Text, Text], bool]
|
||||
_AttributeDict = Dict[Text, Union[Container[Text], _AttributeFilter]]
|
||||
_Attributes = Union[_AttributeFilter, _AttributeDict, List[Text]]
|
||||
|
||||
def attribute_filter_factory(attributes: Union[_AttributeFilter, _AttributeDict, Container[Text]]) -> _AttributeFilter: ...
|
||||
def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ...
|
||||
|
||||
class BleachSanitizerFilter(object): # TODO: derives from html5lib.sanitizer.Filter
|
||||
def __getattr__(self, item: str) -> Any: ... # incomplete
|
||||
class BleachSanitizerFilter(SanitizerFilter):
|
||||
attr_filter: _AttributeFilter
|
||||
strip_disallowed_elements: bool
|
||||
strip_html_comments: bool
|
||||
def __init__(
|
||||
self,
|
||||
source,
|
||||
attributes: _Attributes = ...,
|
||||
strip_disallowed_elements: bool = ...,
|
||||
strip_html_comments: bool = ...,
|
||||
**kwargs,
|
||||
) -> None: ...
|
||||
def sanitize_stream(self, token_iterator): ...
|
||||
def merge_characters(self, token_iterator): ...
|
||||
def __iter__(self): ...
|
||||
def sanitize_token(self, token): ...
|
||||
def sanitize_characters(self, token): ...
|
||||
def sanitize_uri_value(self, value, allowed_protocols): ...
|
||||
def allow_token(self, token): ...
|
||||
def disallowed_token(self, token): ...
|
||||
def sanitize_css(self, style): ...
|
||||
|
||||
Reference in New Issue
Block a user