Exploit databaseDownload repository ZIP
GH-8c7f0e4b0e998904a1d6f7dcd99e3e7d
d-xuan/cve-2024-52510
Sources for CVE-2024-52510
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files2
d-xuan/cve-2024-52510Revision 6c0d89756ae0
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
PHP · 2,246 bytes<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Theming\Listener;
use OCA\Theming\AppInfo\Application;
use OCA\Theming\Service\JSDataService;
use OCA\Theming\Service\ThemeInjectionService;
use OCP\AppFramework\Http\Events\BeforeLoginTemplateRenderedEvent;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\IUserSession;
use Psr\Container\ContainerInterface;
/** @template-implements IEventListener<BeforeTemplateRenderedEvent|BeforeLoginTemplateRenderedEvent> */
class BeforeTemplateRenderedListener implements IEventListener {
private IInitialState $initialState;
private ContainerInterface $container;
private ThemeInjectionService $themeInjectionService;
private IUserSession $userSession;
private IConfig $config;
public function __construct(
IInitialState $initialState,
ContainerInterface $container,
ThemeInjectionService $themeInjectionService,
IUserSession $userSession,
IConfig $config
) {
$this->initialState = $initialState;
$this->container = $container;
$this->themeInjectionService = $themeInjectionService;
$this->userSession = $userSession;
$this->config = $config;
}
public function handle(Event $event): void {
$this->initialState->provideLazyInitialState(
'data',
fn () => $this->container->get(JSDataService::class),
);
/** @var BeforeTemplateRenderedEvent|BeforeLoginTemplateRenderedEvent $event */
if ($event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_USER) {
$this->initialState->provideLazyInitialState('shortcutsDisabled', function () {
if ($this->userSession->getUser()) {
$uid = $this->userSession->getUser()->getUID();
return $this->config->getUserValue($uid, Application::APP_ID, 'shortcuts_disabled', 'no') === 'yes';
}
return false;
});
}
$this->themeInjectionService->injectHeaders();
// Making sure to inject just after core
\OCP\Util::addScript('theming', 'theming', 'core');
}
}