diff options
| author | postie | 2026-03-12 21:32:29 +0000 |
|---|---|---|
| committer | jade (winter) | 2026-04-16 16:08:10 +0100 |
| commit | d4ce56b9018589e5157efca7f07e23c5e44ffe29 (patch) | |
| tree | ee5590635de4a5d0faae99131b2334562bb94f8b /Digitigrade | |
| parent | c88d5c27f2af80cb08435761cc95994244808177 (diff) | |
Only download up to 256KiB of HTML for LinkPreview
Diffstat (limited to 'Digitigrade')
| -rw-r--r-- | Digitigrade/LinkPreview.php | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Digitigrade/LinkPreview.php b/Digitigrade/LinkPreview.php index 706c3c7..718a196 100644 --- a/Digitigrade/LinkPreview.php +++ b/Digitigrade/LinkPreview.php @@ -32,7 +32,8 @@ class LinkPreview implements \JsonSerializable { // TODO: Respect Content-Type header from response, maybe set an Accept header in the request? // I was able to find a URL serving SHIFT-JIS, but they do not specify a charset in the Content-Type header. // https://www2d.biglobe.ne.jp/~msyk/charcode/cp932/Windows-31J-charset.html - $c = @file_get_contents($this->url); + $max_length = 256 * 1024; // 256KiB should be enough for the document head + $c = @file_get_contents($this->url, false, null, 0, $max_length); if (!$c) return false; $d = \Dom\HTMLDocument::createFromString($c, LIBXML_NOERROR); |
