mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-25 19:09:49 +00:00
Show HTML files in the HTML sandbox if enabled
This commit is contained in:
parent
63dd344c02
commit
4a5cc454ce
3 changed files with 50 additions and 1 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue