From 9bff478af3dd87e0a46fa899cd9f6fc5a12a0339 Mon Sep 17 00:00:00 2001 From: jameswade Date: Tue, 12 Jul 2022 17:14:46 +0100 Subject: [PATCH] fix: apply changes from patch --- src/Options.php | 13 +++++++++++++ tests/DompdfTest.php | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Options.php b/src/Options.php index 20e99253e..8e4dcb15b 100644 --- a/src/Options.php +++ b/src/Options.php @@ -296,6 +296,19 @@ public function __construct(array $attributes = null) $this->setTempDir(sys_get_temp_dir()); $this->setFontDir($rootDir . "/lib/fonts"); $this->setFontCache($this->getFontDir()); + + $ver = ""; + $versionFile = realpath(__DIR__ . "/../VERSION"); + if (file_exists($versionFile) && ($version = trim(file_get_contents($versionFile))) !== false && $version !== '$Format:<%h>$') { + $ver = "/$version"; + } + $this->setHttpContext([ + "http" => [ + "follow_location" => false, + "user_agent" => "Dompdf$ver https://github.com/dompdf/dompdf" + ] + ]); + $this->setLogOutputFile($this->getTempDir() . "/log.htm"); if (null !== $attributes) { diff --git a/tests/DompdfTest.php b/tests/DompdfTest.php index 7e376ccfd..9e3dc16f5 100644 --- a/tests/DompdfTest.php +++ b/tests/DompdfTest.php @@ -21,7 +21,6 @@ public function testConstructor() $this->assertIsArray($dompdf->getCallbacks()); $this->assertInstanceOf(Stylesheet::class, $dompdf->getCss()); $this->assertNull($dompdf->getDom()); - $this->assertNull($dompdf->getHttpContext()); $this->assertInstanceOf(Options::class, $dompdf->getOptions()); $this->assertFalse($dompdf->getQuirksmode()); $this->assertNull($dompdf->getTree());