mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Added untrusted server fetching control
WKHTMLtoPDF provides limited control for external fetching so that will now be disabled by default unless ALLOW_UNTRUSTED_SERVER_FETCHING=true is specifically set. This new option will also control DOMPDF fetching.
This commit is contained in:
@ -366,4 +366,20 @@ class ExportTest extends TestCase
|
||||
$this->assertPermissionError($resp);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_wkhtmltopdf_only_used_when_allow_untrusted_is_true()
|
||||
{
|
||||
/** @var Page $page */
|
||||
$page = Page::query()->first();
|
||||
|
||||
config()->set('snappy.pdf.binary', '/abc123');
|
||||
config()->set('app.allow_untrusted_server_fetching', false);
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/pdf'));
|
||||
$resp->assertStatus(200); // Sucessful response with invalid snappy binary indicates dompdf usage.
|
||||
|
||||
config()->set('app.allow_untrusted_server_fetching', true);
|
||||
$resp = $this->get($page->getUrl('/export/pdf'));
|
||||
$resp->assertStatus(500); // Bad response indicates wkhtml usage
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,12 @@ class ConfigTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_dompdf_remote_fetching_controlled_by_allow_untrusted_server_fetching_false()
|
||||
{
|
||||
$this->checkEnvConfigResult('ALLOW_UNTRUSTED_SERVER_FETCHING', 'false', 'dompdf.defines.enable_remote', false);
|
||||
$this->checkEnvConfigResult('ALLOW_UNTRUSTED_SERVER_FETCHING', 'true', 'dompdf.defines.enable_remote', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable of the given name and value
|
||||
* then check the given config key to see if it matches the given result.
|
||||
|
Reference in New Issue
Block a user