Update bleach stubs to version 5 (#7612)

This commit is contained in:
Sebastian Rittau
2022-04-12 02:48:55 +02:00
committed by GitHub
parent 40553277ad
commit 636a7e8b37
6 changed files with 23 additions and 18 deletions

View File

@@ -1 +1,2 @@
bleach.css_sanitizer # Requires tinycss2 to be installed
bleach.html5lib_shim.*

View File

@@ -1 +1 @@
version = "4.1.*"
version = "5.0.*"

View File

@@ -1,11 +1,10 @@
from collections.abc import Container, Iterable
from typing import Any
from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
from bleach.sanitizer import (
from .css_sanitizer import CSSSanitizer
from .linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
from .sanitizer import (
ALLOWED_ATTRIBUTES as ALLOWED_ATTRIBUTES,
ALLOWED_PROTOCOLS as ALLOWED_PROTOCOLS,
ALLOWED_STYLES as ALLOWED_STYLES,
ALLOWED_TAGS as ALLOWED_TAGS,
Cleaner as Cleaner,
_Attributes,
@@ -15,16 +14,15 @@ __all__ = ["clean", "linkify"]
__releasedate__: str
__version__: str
VERSION: Any # packaging.version.Version
def clean(
text: str,
tags: Container[str] = ...,
attributes: _Attributes = ...,
styles: Container[str] = ...,
protocols: Container[str] = ...,
strip: bool = ...,
strip_comments: bool = ...,
css_sanitizer: CSSSanitizer | None = ...,
) -> str: ...
def linkify(
text: str, callbacks: Iterable[_Callback] = ..., skip_tags: Container[str] | None = ..., parse_email: bool = ...

View File

@@ -0,0 +1,11 @@
from collections.abc import Container
ALLOWED_CSS_PROPERTIES: frozenset[str]
ALLOWED_SVG_PROPERTIES: frozenset[str]
class CSSSanitizer:
allowed_css_properties: Container[str]
allowed_svg_properties: Container[str]
def __init__(self, allowed_css_properties: Container[str] = ..., allowed_svg_properties: Container[str] = ...) -> None: ...
def sanitize_css(self, style: str) -> str: ...

View File

@@ -1,11 +1,11 @@
from collections.abc import Callable, Container, Iterable
from typing import Any, Pattern
from .css_sanitizer import CSSSanitizer
from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter
ALLOWED_TAGS: list[str]
ALLOWED_ATTRIBUTES: dict[str, list[str]]
ALLOWED_STYLES: list[str]
ALLOWED_PROTOCOLS: list[str]
INVISIBLE_CHARACTERS: str
@@ -18,11 +18,11 @@ _Filter = Any
class Cleaner:
tags: Container[str]
attributes: _Attributes
styles: Container[str]
protocols: Container[str]
strip: bool
strip_comments: bool
filters: Iterable[_Filter]
css_sanitizer: CSSSanitizer | None
parser: BleachHTMLParser
walker: Any
serializer: BleachHTMLSerializer
@@ -30,11 +30,11 @@ class Cleaner:
self,
tags: Container[str] = ...,
attributes: _Attributes = ...,
styles: Container[str] = ...,
protocols: Container[str] = ...,
strip: bool = ...,
strip_comments: bool = ...,
filters: Iterable[_Filter] | None = ...,
css_sanitizer: CSSSanitizer | None = ...,
) -> None: ...
def clean(self, text: str) -> str: ...
@@ -51,9 +51,12 @@ class BleachSanitizerFilter(SanitizerFilter):
def __init__(
self,
source,
allowed_elements: Container[str] = ...,
attributes: _Attributes = ...,
allowed_protocols: Container[str] = ...,
strip_disallowed_elements: bool = ...,
strip_html_comments: bool = ...,
css_sanitizer: CSSSanitizer | None = ...,
**kwargs,
) -> None: ...
def sanitize_stream(self, token_iterator): ...

View File

@@ -1,8 +0,0 @@
from collections import OrderedDict
from collections.abc import Mapping
from typing import Any, overload
@overload
def alphabetize_attributes(attrs: None) -> None: ...
@overload
def alphabetize_attributes(attrs: Mapping[Any, str]) -> OrderedDict[Any, str]: ...