From 3fd62dcd6f8772cc5a04a40026ee57d8120326de Mon Sep 17 00:00:00 2001 From: shibafu Date: Sat, 17 Oct 2020 16:54:00 +0900 Subject: [PATCH] =?UTF-8?q?robots.txt=E5=8F=96=E5=BE=97=E6=99=82=E3=80=81t?= =?UTF-8?q?ext/plain=E4=BB=A5=E5=A4=96=E3=81=AE=E5=BF=9C=E7=AD=94=E3=81=AF?= =?UTF-8?q?=E5=A4=B1=E6=95=97=E6=89=B1=E3=81=84=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetadataResolveService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index dec8479..8446fa1 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -162,6 +162,11 @@ class MetadataResolveService $client = app(Client::class); try { $res = $client->get($robotsUrl); + if (stripos($res->getHeaderLine('Content-Type'), 'text/plain') !== 0) { + Log::error('robots.txtの取得に失敗: 不適切なContent-Type (' . $res->getHeaderLine('Content-Type') . ')'); + + return null; + } return (string) $res->getBody(); } catch (\Exception $e) {