<?php 
 
/* 
 * This file is part of EC-CUBE 
 * 
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. 
 * 
 * http://www.ec-cube.co.jp/ 
 * 
 * For the full copyright and license information, please view the LICENSE 
 * file that was distributed with this source code. 
 */ 
 
namespace Eccube\Form\EventListener; 
 
use Symfony\Component\EventDispatcher\EventSubscriberInterface; 
use Symfony\Component\Form\FormEvent; 
use Symfony\Component\Form\FormEvents; 
 
class HTMLPurifierListener implements EventSubscriberInterface 
{ 
    /** 
     * @return array[] 
     */ 
    public static function getSubscribedEvents(): array 
    { 
        return [ 
            FormEvents::PRE_SUBMIT => ['purifySubmittedData', /* as soon as possible */ 1000001], 
        ]; 
    } 
 
    public function purifySubmittedData(FormEvent $event): void 
    { 
        $event->setData(str_replace(['<', '>', '&'], ['<', '>', '&'], $event->getData())); 
    } 
}