massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / bleach / bleach / sanitizer.pyi
1 from collections.abc import Callable, Container, Iterable
2 from typing import Any, Dict, List, Pattern, Union
3
4 from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter
5
6 ALLOWED_TAGS: list[str]
7 ALLOWED_ATTRIBUTES: dict[str, list[str]]
8 ALLOWED_STYLES: list[str]
9 ALLOWED_PROTOCOLS: list[str]
10
11 INVISIBLE_CHARACTERS: str
12 INVISIBLE_CHARACTERS_RE: Pattern[str]
13 INVISIBLE_REPLACEMENT_CHAR: str
14
15 # A html5lib Filter class
16 _Filter = Any
17
18 class Cleaner(object):
19     tags: Container[str]
20     attributes: _Attributes
21     styles: Container[str]
22     protocols: Container[str]
23     strip: bool
24     strip_comments: bool
25     filters: Iterable[_Filter]
26     parser: BleachHTMLParser
27     walker: Any
28     serializer: BleachHTMLSerializer
29     def __init__(
30         self,
31         tags: Container[str] = ...,
32         attributes: _Attributes = ...,
33         styles: Container[str] = ...,
34         protocols: Container[str] = ...,
35         strip: bool = ...,
36         strip_comments: bool = ...,
37         filters: Iterable[_Filter] | None = ...,
38     ) -> None: ...
39     def clean(self, text: str) -> str: ...
40
41 _AttributeFilter = Callable[[str, str, str], bool]
42 _AttributeDict = Union[Dict[str, Union[List[str], _AttributeFilter]], Dict[str, List[str]], Dict[str, _AttributeFilter]]
43 _Attributes = Union[_AttributeFilter, _AttributeDict, List[str]]
44
45 def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ...
46
47 class BleachSanitizerFilter(SanitizerFilter):
48     attr_filter: _AttributeFilter
49     strip_disallowed_elements: bool
50     strip_html_comments: bool
51     def __init__(
52         self,
53         source,
54         attributes: _Attributes = ...,
55         strip_disallowed_elements: bool = ...,
56         strip_html_comments: bool = ...,
57         **kwargs,
58     ) -> None: ...
59     def sanitize_stream(self, token_iterator): ...
60     def merge_characters(self, token_iterator): ...
61     def __iter__(self): ...
62     def sanitize_token(self, token): ...
63     def sanitize_characters(self, token): ...
64     def sanitize_uri_value(self, value, allowed_protocols): ...
65     def allow_token(self, token): ...
66     def disallowed_token(self, token): ...
67     def sanitize_css(self, style): ...