Take redirects off the Host header.

Same-site redirects are now relative paths, and a saved page on another site is ignored. The HTTP to HTTPS redirect takes its host from the new SITE_URL setting, and without it the pages refuse plain HTTP.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent 4657088d23
commit be814a3ba5
16 changed files with 149 additions and 73 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Xxx\Tests\Pages;
use Xxx\Tests\Support\PageTestCase;
// require_https() in config.lib.php when SITE_URL is empty
class HttpsTest extends PageTestCase {
protected static function serverEnv(): array {
// proc_open() drops a variable with an empty value, so use a blank one
return array('SITE_URL' => ' ');
}
public function testWithoutASiteUrlPlainHttpIsRefused(): void {
$answer = $this->get('/publish/login', array('X-Test-Plain' => '1'));
$this->assertSame(403, $answer['status']);
$this->assertNull($this->header($answer, 'Location'));
$this->assertSame("This page needs HTTPS.\n", $answer['body']);
}
public function testWithoutASiteUrlHttpsStillWorks(): void {
$this->assertSame(200, $this->get('/publish/login')['status']);
}
}