Вход Регистрация
Файл: vendor/symfony/html-sanitizer/Visitor/AttributeSanitizer/UrlAttributeSanitizer.php
Строк: 84
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SymfonyComponentHtmlSanitizerVisitorAttributeSanitizer;

use 
SymfonyComponentHtmlSanitizerHtmlSanitizerConfig;
use 
SymfonyComponentHtmlSanitizerTextSanitizerUrlSanitizer;

/**
 * @author Titouan Galopin <galopintitouan@gmail.com>
 */
final class UrlAttributeSanitizer implements AttributeSanitizerInterface
{
    public function 
getSupportedElements(): ?array
    {
        
// Check all elements for URL attributes
        
return null;
    }

    public function 
getSupportedAttributes(): ?array
    {
        return [
'src''href''lowsrc''background''ping''action''formaction''poster''cite''data''codebase''archive''longdesc'];
    }

    public function 
sanitizeAttribute(string $elementstring $attributestring $valueHtmlSanitizerConfig $config): ?string
    
{
        if (
in_array($element, ['a''area'], true) || in_array($attribute, ['action''formaction''cite'], true)) {
            return 
UrlSanitizer::sanitize(
                
$value,
                
$config->getAllowedLinkSchemes(),
                
$config->getForceHttpsUrls(),
                
$config->getAllowedLinkHosts(),
                
$config->getAllowRelativeLinks(),
            );
        }

        return 
UrlSanitizer::sanitize(
            
$value,
            
$config->getAllowedMediaSchemes(),
            
$config->getForceHttpsUrls(),
            
$config->getAllowedMediaHosts(),
            
$config->getAllowRelativeMedias(),
        );
    }
}
Онлайн: 2
Реклама