Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/Files/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function handle(Event $event): void {

Util::addScript(Application::APP_ID, 'libresign-tab');
Util::addStyle(Application::APP_ID, 'libresign-tab');
Util::addStyle(Application::APP_ID, 'icons');
}

protected function getInitialStatePayload(): array {
Expand Down
54 changes: 54 additions & 0 deletions tests/php/Unit/Files/TemplateLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace OCA\Libresign\Tests\Unit\Files;

use OCA\Files\Event\LoadSidebar;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Files\TemplateLoader;
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
use OCA\Libresign\Handler\CertificateEngine\IEngineHandler;
Expand Down Expand Up @@ -141,4 +143,56 @@ private function getLoader(): TemplateLoader {
$this->docMdpConfigService,
);
}

/**
* Regression test for https://github.com/LibreSign/libresign/issues/7632
*
* The `icons` CSS style must NOT be registered separately because:
* 1. It does not exist as a standalone CSS file in the Vite build output.
* 2. Its content (.icon-libresign) is already bundled inside `libresign-tab`.
* Loading a non-existent file causes a 404 on every page load with the
* files sidebar, and any unscoped `list-style` rule in that file would
* bleed into other Nextcloud apps (e.g. Notes, Markdown).
*/
public function testHandleDoesNotRegisterIconsStyleSeparately(): void {
$this->appManager
->method('isEnabledForUser')
->with('libresign')
->willReturn(true);

$engine = $this->createMock(IEngineHandler::class);
$engine->method('isSetupOk')->willReturn(true);
$this->certificateEngineFactory
->method('getEngine')
->willReturn($engine);
$this->identifyMethodService
->method('getIdentifyMethodsSettings')
->willReturn([]);
$this->appConfig
->method('getValueString')
->willReturn('none');
$this->docMdpConfigService
->method('getConfig')
->willReturn([]);
$user = $this->createMock(IUser::class);
$this->userSession
->method('getUser')
->willReturn($user);

$stylesBefore = \OC_Util::$styles;
$loader = $this->getLoader();
$loader->handle(new LoadSidebar());
$stylesAfter = \OC_Util::$styles;

$newStyles = array_diff($stylesAfter, $stylesBefore);
$iconsStylePath = Application::APP_ID . '/css/icons';

foreach ($newStyles as $style) {
$this->assertStringNotContainsString(
$iconsStylePath,
$style,
'The "icons" CSS must not be registered separately — it is already bundled in libresign-tab and loading it would cause a 404 and potential global CSS leaks (issue #7632).'
);
}
}
}
Loading