Maintenance: Fixed test issues from recent changes

This commit is contained in:
Dan Brown
2026-07-28 15:19:20 +01:00
parent badc4f9b8e
commit a0108ae0ea
5 changed files with 11 additions and 9 deletions
@@ -30,7 +30,7 @@ class ExternalBaseSessionGuard implements StatefulGuard
/**
* The user we last attempted to retrieve.
*/
protected Authenticatable|null $lastAttempted;
protected Authenticatable|null $lastAttempted = null;
/**
* The session used by the guard.
@@ -203,7 +203,7 @@ class ExternalBaseSessionGuard implements StatefulGuard
/**
* Get the last user we attempted to authenticate.
*/
public function getLastAttempted(): Authenticatable
public function getLastAttempted(): Authenticatable|null
{
return $this->lastAttempted;
}
+4 -1
View File
@@ -13,6 +13,7 @@ use BookStack\Permissions\Permission;
use BookStack\Theming\ThemeEvents;
use BookStack\Users\Models\User;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\Hash;
class LoginService
@@ -178,7 +179,9 @@ class LoginService
// Perform a dummy hash check to balance out the time of a login with an existing known user
// with that of a user not in the system (which we don't perform a hash check for in the above).
if (!$result && auth()->getLastAttempted() === null) {
/** @var Authenticatable|null $lastAttempted */
$lastAttempted = auth()->getLastAttempted();
if (!$result && $lastAttempted === null) {
Hash::check($credentials['password'], '$2y$04$A.H9icXH4/lxLd9DHuaYqO/GVBd0OKetxyY0txmNfTAlPLVnTBx3y');
}
+3 -3
View File
@@ -87,7 +87,7 @@ class SrcsetAttrDef extends HTMLPurifier_AttrDef
}
if ($state === 'in_descriptor') {
if ($c !== null && strpos($asciiWhitespace, $c) !== false) {
if ($c !== null && str_contains($asciiWhitespace, $c)) {
if ($currentDescriptor !== '') {
$descriptors[] = $currentDescriptor;
}
@@ -119,8 +119,8 @@ class SrcsetAttrDef extends HTMLPurifier_AttrDef
} else {
$currentDescriptor .= $c;
}
} else if ($state === 'after_descriptor') {
if ($c !== null && strpos($asciiWhitespace, $c) !== false) {
} else {
if ($c !== null && str_contains($asciiWhitespace, $c)) {
// Stay in this state
} else if ($c === null) {
break;
+1 -2
View File
@@ -166,8 +166,7 @@ class HtmlExportTest extends TestCase
$storageDisk->delete('uploads/svg_test.svg');
$resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test.svg', false);
$resp->assertSee('http://localhost/uploads/svg_test.svg');
$resp->assertSee('src="/uploads/svg_test.svg"', false);
$resp->assertSee('src="http://localhost/uploads/svg_test.svg"', false);
}
public function test_page_export_contained_html_does_not_allow_upward_traversal_with_local()
+1 -1
View File
@@ -58,7 +58,7 @@ class PdfExportTest extends TestCase
$this->asEditor()->get($page->getUrl('/export/pdf'));
$this->assertStringNotContainsString('iframe>', $pdfHtml);
$this->assertStringContainsString('<p><a href="https://www.youtube.com/embed/ShqUjt33uOs">https://www.youtube.com/embed/ShqUjt33uOs</a></p>', $pdfHtml);
$this->assertStringContainsString('<p><a href="http://www.youtube.com/embed/ShqUjt33uOs">http://www.youtube.com/embed/ShqUjt33uOs</a></p>', $pdfHtml);
}
public function test_page_pdf_export_opens_details_blocks()