Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

Filter event description HTML

Dave Earley10b1bdb6edff
diff --git a/backend/app/Services/Domain/Event/CreateEventService.php b/backend/app/Services/Domain/Event/CreateEventService.php
index dbc233307..6c743a4af 100644
--- a/backend/app/Services/Domain/Event/CreateEventService.php
+++ b/backend/app/Services/Domain/Event/CreateEventService.php
@@ -13,6 +13,7 @@ use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Repository\Interfaces\EventSettingsRepositoryInterface;
use HiEvents\Repository\Interfaces\EventStatisticRepositoryInterface;
use HiEvents\Repository\Interfaces\OrganizerRepositoryInterface;
+use HTMLPurifier;
use Illuminate\Database\DatabaseManager;
use Throwable;
@@ -24,6 +25,7 @@ class CreateEventService
private readonly OrganizerRepositoryInterface $organizerRepository,
private readonly DatabaseManager $databaseManager,
private readonly EventStatisticRepositoryInterface $eventStatisticsRepository,
+ private readonly HTMLPurifier $purifier,
)
{
}
@@ -86,7 +88,7 @@ class CreateEventService
'end_date' => $eventData->getEndDate()
? DateHelper::convertToUTC($eventData->getEndDate(), $eventData->getTimezone())
: null,
- 'description' => $eventData->getDescription(),
+ 'description' => $this->purifier->purify($eventData->getDescription()),
'timezone' => $eventData->getTimezone(),
'currency' => $eventData->getCurrency(),
'location_details' => $eventData->getLocationDetails(),
diff --git a/backend/app/Services/Domain/Event/DuplicateEventService.php b/backend/app/Services/Domain/Event/DuplicateEventService.php
index 8ee07d131..6cd2db6b1 100644
--- a/backend/app/Services/Domain/Event/DuplicateEventService.php
+++ b/backend/app/Services/Domain/Event/DuplicateEventService.php
@@ -15,6 +15,7 @@ use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Services\Domain\PromoCode\CreatePromoCodeService;
use HiEvents\Services\Domain\Question\CreateQuestionService;
use HiEvents\Services\Domain\Ticket\CreateTicketService;
+use HTMLPurifier;
use Illuminate\Database\DatabaseManager;
use Throwable;
@@ -27,6 +28,7 @@ class DuplicateEventService
private readonly CreateQuestionService $createQuestionService,
private readonly CreatePromoCodeService $createPromoCodeService,
private readonly DatabaseManager $databaseManager,
+ private readonly HTMLPurifier $purifier,
)
{
}
@@ -55,7 +57,7 @@ class DuplicateEventService
->setTitle($title)
->setStartDate($startDate)
->setEndDate($endDate)
- ->setDescription($description)
+ ->setDescription($this->purifier->purify($description))
->setStatus(EventStatus::DRAFT->name);
$newEvent = $this->cloneExistingEvent(
diff --git a/backend/app/Services/Handlers/Event/UpdateEventHandler.php b/backend/app/Services/Handlers/Event/UpdateEventHandler.php
index 7e764a6d5..f872725a3 100644
--- a/backend/app/Services/Handlers/Event/UpdateEventHandler.php
+++ b/backend/app/Services/Handlers/Event/UpdateEventHandler.php
@@ -11,6 +11,7 @@ use HiEvents\Helper\DateHelper;
use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Repository\Interfaces\OrderRepositoryInterface;
use HiEvents\Services\Handlers\Event\DTO\UpdateEventDTO;
+use HTMLPurifier;
use Illuminate\Database\DatabaseManager;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Throwable;
@@ -22,6 +23,7 @@ readonly class UpdateEventHandler
private Dispatcher $dispatcher,
private DatabaseManager $databaseManager,
private OrderRepositoryInterface $orderRepository,
+ private HTMLPurifier $purifier,
)
{
}
@@ -72,7 +74,7 @@ readonly class UpdateEventHandler
'end_date' => $eventData->end_date
? DateHelper::convertToUTC($eventData->end_date, $eventData->timezone)
: null,
- 'description' => $eventData->description,
+ 'description' => $this->purifier->purify($eventData->description),
'timezone' => $eventData->timezone ?? $existingEvent->getTimezone(),
'currency' => $eventData->currency ?? $existingEvent->getCurrency(),
'location' => $eventData->location,