Skip to content

Commit 9ffbc3b

Browse files
authored
Merge pull request #7641 from LibreSign/fix/7632-remove-stale-icons-addstyle
fix(Files): remove stale addStyle icons call from TemplateLoader
2 parents 81feadf + 3c7a808 commit 9ffbc3b

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

lib/Files/TemplateLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function handle(Event $event): void {
5959

6060
Util::addScript(Application::APP_ID, 'libresign-tab');
6161
Util::addStyle(Application::APP_ID, 'libresign-tab');
62-
Util::addStyle(Application::APP_ID, 'icons');
6362
}
6463

6564
protected function getInitialStatePayload(): array {

tests/php/Unit/Files/TemplateLoaderTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace OCA\Libresign\Tests\Unit\Files;
1010

11+
use OCA\Files\Event\LoadSidebar;
12+
use OCA\Libresign\AppInfo\Application;
1113
use OCA\Libresign\Files\TemplateLoader;
1214
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
1315
use OCA\Libresign\Handler\CertificateEngine\IEngineHandler;
@@ -141,4 +143,56 @@ private function getLoader(): TemplateLoader {
141143
$this->docMdpConfigService,
142144
);
143145
}
146+
147+
/**
148+
* Regression test for https://github.com/LibreSign/libresign/issues/7632
149+
*
150+
* The `icons` CSS style must NOT be registered separately because:
151+
* 1. It does not exist as a standalone CSS file in the Vite build output.
152+
* 2. Its content (.icon-libresign) is already bundled inside `libresign-tab`.
153+
* Loading a non-existent file causes a 404 on every page load with the
154+
* files sidebar, and any unscoped `list-style` rule in that file would
155+
* bleed into other Nextcloud apps (e.g. Notes, Markdown).
156+
*/
157+
public function testHandleDoesNotRegisterIconsStyleSeparately(): void {
158+
$this->appManager
159+
->method('isEnabledForUser')
160+
->with('libresign')
161+
->willReturn(true);
162+
163+
$engine = $this->createMock(IEngineHandler::class);
164+
$engine->method('isSetupOk')->willReturn(true);
165+
$this->certificateEngineFactory
166+
->method('getEngine')
167+
->willReturn($engine);
168+
$this->identifyMethodService
169+
->method('getIdentifyMethodsSettings')
170+
->willReturn([]);
171+
$this->appConfig
172+
->method('getValueString')
173+
->willReturn('none');
174+
$this->docMdpConfigService
175+
->method('getConfig')
176+
->willReturn([]);
177+
$user = $this->createMock(IUser::class);
178+
$this->userSession
179+
->method('getUser')
180+
->willReturn($user);
181+
182+
$stylesBefore = \OC_Util::$styles;
183+
$loader = $this->getLoader();
184+
$loader->handle(new LoadSidebar());
185+
$stylesAfter = \OC_Util::$styles;
186+
187+
$newStyles = array_diff($stylesAfter, $stylesBefore);
188+
$iconsStylePath = Application::APP_ID . '/css/icons';
189+
190+
foreach ($newStyles as $style) {
191+
$this->assertStringNotContainsString(
192+
$iconsStylePath,
193+
$style,
194+
'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).'
195+
);
196+
}
197+
}
144198
}

0 commit comments

Comments
 (0)