Show HTML files in the HTML sandbox if enabled

This commit is contained in:
Jan Böhmer 2026-02-24 22:40:23 +01:00
parent 63dd344c02
commit 4a5cc454ce
3 changed files with 50 additions and 1 deletions

View file

@ -279,4 +279,32 @@ final class AttachmentTest extends TestCase
$reflection_property->setAccessible(true);
$reflection_property->setValue($object, $value);
}
public function testIsLocalHTMLFile(): void
{
$attachment = new PartAttachment();
$attachment->setExternalPath('https://google.de');
$this->assertFalse($attachment->isLocalHTMLFile());
$attachment->setExternalPath('https://google.de/test.html');
$this->assertFalse($attachment->isLocalHTMLFile());
$attachment->setInternalPath('%MEDIA%/test.html');
$this->assertTrue($attachment->isLocalHTMLFile());
$attachment->setInternalPath('%MEDIA%/test.htm');
$this->assertTrue($attachment->isLocalHTMLFile());
$attachment->setInternalPath('%MEDIA%/test.txt');
$this->assertFalse($attachment->isLocalHTMLFile());
//It works however, if the file is stored as txt, and the internal filename ends with .html
$attachment->setInternalPath('%MEDIA%/test.txt');
$this->setProtectedProperty($attachment, 'original_filename', 'test.html');
$this->assertTrue($attachment->isLocalHTMLFile());
$this->setProtectedProperty($attachment, 'original_filename', 'test.htm');
$this->assertTrue($attachment->isLocalHTMLFile());
}
}