forked from GNUsocial/gnu-social
[DEPENDENCY] Add tgalopin/html-sanitizer-bundle and transitively tgalopin/html-sanitizer
This commit is contained in:
@@ -48,6 +48,7 @@ use App\Core\I18n\I18n;
|
||||
use App\Core\Queue\Queue;
|
||||
use App\Core\Router\Router;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use HtmlSanitizer\SanitizerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@@ -56,7 +57,6 @@ use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
@@ -80,9 +80,10 @@ class GNUsocial implements EventSubscriberInterface
|
||||
protected EventDispatcherInterface $event_dispatcher;
|
||||
protected SessionInterface $session;
|
||||
protected SSecurity $security;
|
||||
protected MailerInterface $mailer;
|
||||
protected ModuleManager $module_manager;
|
||||
protected Httpclientinterface $client;
|
||||
protected HttpClientInterface $client;
|
||||
protected SanitizerInterface $sanitizer;
|
||||
|
||||
/**
|
||||
* Symfony dependency injection gives us access to these services
|
||||
*/
|
||||
@@ -96,9 +97,9 @@ class GNUsocial implements EventSubscriberInterface
|
||||
EventDispatcherInterface $ed,
|
||||
SessionInterface $sess,
|
||||
SSecurity $sec,
|
||||
MailerInterface $mail,
|
||||
ModuleManager $mm,
|
||||
HttpClientInterface $cl)
|
||||
HttpClientInterface $cl,
|
||||
SanitizerInterface $san)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
$this->translator = $trans;
|
||||
@@ -110,9 +111,9 @@ class GNUsocial implements EventSubscriberInterface
|
||||
$this->event_dispatcher = $ed;
|
||||
$this->session = $sess;
|
||||
$this->security = $sec;
|
||||
$this->mailer = $mail;
|
||||
$this->module_manager = $mm;
|
||||
$this->client = $cl;
|
||||
$this->saniter = $san;
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
@@ -131,8 +132,7 @@ class GNUsocial implements EventSubscriberInterface
|
||||
DB::setManager($this->entity_manager);
|
||||
Form::setFactory($this->form_factory);
|
||||
Queue::setMessageBus($this->message_bus);
|
||||
Security::setHelper($this->security);
|
||||
Mailer::setMailer($this->mailer);
|
||||
Security::setHelper($this->security, $this->saniter);
|
||||
Router::setRouter($this->router, $this->url_generator);
|
||||
HTTPClient::setClient($this->client);
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
// {{{ License
|
||||
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Mailer wrapper
|
||||
*
|
||||
* @package GNUsocial
|
||||
* @category Wrapper
|
||||
*
|
||||
* @author Hugo Sales <hugo@fc.up.pt>
|
||||
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
|
||||
abstract class Mailer
|
||||
{
|
||||
private static MailerInterface $mailer;
|
||||
public static function setMailer($m)
|
||||
{
|
||||
self::$mailer = $m;
|
||||
}
|
||||
|
||||
public static function __callStatic(string $method, array $args)
|
||||
{
|
||||
return self::{$method}(...$args);
|
||||
}
|
||||
}
|
||||
@@ -30,19 +30,26 @@
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use HtmlSanitizer\SanitizerInterface;
|
||||
use Symfony\Component\Security\Core\Security as SSecurity;
|
||||
|
||||
abstract class Security
|
||||
{
|
||||
private static ?SSecurity $security;
|
||||
private static ?SanitizerInterface $sanitizer;
|
||||
|
||||
public static function setHelper($s): void
|
||||
public static function setHelper($sec, $san): void
|
||||
{
|
||||
self::$security = $s;
|
||||
self::$security = $sec;
|
||||
self::$sanitizer = $san;
|
||||
}
|
||||
|
||||
public static function __callStatic(string $name, array $args)
|
||||
{
|
||||
return self::$security->{$name}(...$args);
|
||||
if (method_exists(self::$security, $name)) {
|
||||
return self::$security->{$name}(...$args);
|
||||
} else {
|
||||
return self::$sanitizer->{$name}(...$args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user