pdf.fetcher

Classes

AllowlistURLFetcher

WeasyPrint URL fetcher that only fetches the given URLs.

SafeHTML

weasyprint.HTML that fetches nothing but allowed_urls.

SafeCSS

weasyprint.CSS that fetches nothing but allowed_urls.

Module Contents

class pdf.fetcher.AllowlistURLFetcher(allowed_urls: collections.abc.Iterable[str] = (), **kwargs: Any)[source]

Bases: weasyprint.urls.URLFetcher

WeasyPrint URL fetcher that only fetches the given URLs.

WeasyPrint’s default fetcher follows any URL in the rendered HTML, including file:// (embedding local files as PDF attachments) and internal hosts (SSRF).

allowed_urls[source]
fetch(url: str, headers: dict[str, str] | None = None) → weasyprint.urls.URLFetcherResponse[source]
class pdf.fetcher.SafeHTML(*args: Any, allowed_urls: collections.abc.Iterable[str] = (), **kwargs: Any)[source]

Bases: weasyprint.HTML

weasyprint.HTML that fetches nothing but allowed_urls.

Direct use of weasyprint.HTML is banned via ruff (TID251).

class pdf.fetcher.SafeCSS(*args: Any, allowed_urls: collections.abc.Iterable[str] = (), **kwargs: Any)[source]

Bases: weasyprint.CSS

weasyprint.CSS that fetches nothing but allowed_urls.

Direct use of weasyprint.CSS is banned via ruff (TID251).