RemoteImageFetcher
in package
Read onlyYes
FinalYes
Downloads remote logos without server-side request forgery: only http and https, only hosts whose every resolved address (IPv4 and IPv6) is publicly routable, the connection pinned to the checked address (no second DNS lookup) and every redirect checked again.
Table of Contents
Methods
- __construct() : mixed
- fetch() : string|null
- Content of the image, or null if it cannot be downloaded.
- isPublicAddress() : bool
- Whether the address is publicly routable: no loopback, private, link-local, shared, reserved, documentation or multicast range, also not embedded in an IPv6 address.
Methods
__construct()
public
__construct([int $maxBytes = 10 * 1024 * 1024 ][, int $timeout = 10 ][, int $maxRedirects = 3 ][, callable(string): array<int, string>|null $resolver = null ][, callable(string, string, string): Array|null $transport = null ]) : mixed
Parameters
- $maxBytes : int = 10 * 1024 * 1024
- $timeout : int = 10
- $maxRedirects : int = 3
- $resolver : callable(string): array<int, string>|null = null
-
host name => IP addresses
- $transport : callable(string, string, string): Array|null = null
-
URL, host, pinned IP => response, null on failure
fetch()
Content of the image, or null if it cannot be downloaded.
public
fetch(string $url) : string|null
Parameters
- $url : string
Tags
Return values
string|nullisPublicAddress()
Whether the address is publicly routable: no loopback, private, link-local, shared, reserved, documentation or multicast range, also not embedded in an IPv6 address.
public
static isPublicAddress(string $ip) : bool
Parameters
- $ip : string