Plugin Directory

Changeset 3165222


Ignore:
Timestamp:
10/08/2024 07:51:39 PM (6 months ago)
Author:
Petrichorpost
Message:

Fixing critical error!

Location:
svgplus/trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • svgplus/trunk/includes/class-svgplus-sanitizer.php

    r3165219 r3165222  
    77
    88use enshrined\svgSanitize\Sanitizer;
     9use enshrined\svgSanitize\Config;
    910
    1011class SVGPlus_Sanitizer {
     
    2425        $sanitizer = new Sanitizer();
    2526
    26         // Get the current config
    27         $config = $sanitizer->getConfig();
     27        // Check if getConfig() method exists
     28        if (method_exists($sanitizer, 'getConfig')) {
     29            $config = $sanitizer->getConfig();
    2830
    29         if ($allow_animations) {
    30             // Include animation elements and attributes
    31             $config->addAllowedTags(['animate', 'animateTransform', 'animateMotion', 'mpath', 'set']);
    32             $config->addAllowedAttrs([
    33                 'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'fill',
    34                 'from', 'keyPoints', 'keySplines', 'keyTimes', 'max', 'min', 'repeatCount',
    35                 'repeatDur', 'restart', 'to', 'values', 'additive', 'accumulate', 'path', 'rotate',
    36                 'origin', 'type'
    37             ]);
     31            if ($allow_animations) {
     32                // Include animation elements and attributes
     33                $config->addAllowedTags(['animate', 'animateTransform', 'animateMotion', 'mpath', 'set']);
     34                $config->addAllowedAttrs([
     35                    'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'fill',
     36                    'from', 'keyPoints', 'keySplines', 'keyTimes', 'max', 'min', 'repeatCount',
     37                    'repeatDur', 'restart', 'to', 'values', 'additive', 'accumulate', 'path', 'rotate',
     38                    'origin', 'type'
     39                ]);
     40            }
     41
     42            // Apply the updated config to the sanitizer
     43            $sanitizer->setConfig($config);
     44        } else {
     45            // For older versions, use constructor with custom config
     46            $config = new Config();
     47
     48            if ($allow_animations) {
     49                // Include animation elements and attributes
     50                $config->addAllowedTags(['animate', 'animateTransform', 'animateMotion', 'mpath', 'set']);
     51                $config->addAllowedAttrs([
     52                    'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'fill',
     53                    'from', 'keyPoints', 'keySplines', 'keyTimes', 'max', 'min', 'repeatCount',
     54                    'repeatDur', 'restart', 'to', 'values', 'additive', 'accumulate', 'path', 'rotate',
     55                    'origin', 'type'
     56                ]);
     57            }
     58
     59            $sanitizer = new Sanitizer($config);
    3860        }
    39 
    40         // Apply the updated config to the sanitizer
    41         $sanitizer->setConfig($config);
    4261
    4362        // Sanitize the SVG
  • svgplus/trunk/readme.txt

    r3165218 r3165222  
    44Requires at least: 5.0
    55Tested up to: 6.6
    6 Stable tag: 1.0.10
     6Stable tag: 1.0.11
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7272## Changelog
    7373
    74 = 1.0.9 =
     74= 1.0.11 =
    7575
    7676- Switched to using the `enshrined/svg-sanitize` library for SVG sanitization.
     
    116116== Upgrade Notice ==
    117117
    118 = 1.0.10 =
     118= 1.0.11 =
    119119
    120120Please update to this version to benefit from improved SVG sanitization and functionality enhancements.
  • svgplus/trunk/svgplus.php

    r3165219 r3165222  
    33 * Plugin Name: SVGPlus
    44 * Description: Upload, sanitize, and display SVG files securely in WordPress.
    5  * Version: 1.0.10
     5 * Version: 1.0.11
    66 * Author: Rizonepress
    77 * License: GPL2
     
    1414
    1515// Include Composer's autoloader
    16 require_once __DIR__ . '/vendor/autoload.php';
     16if (file_exists(__DIR__ . '/vendor/autoload.php')) {
     17    require_once __DIR__ . '/vendor/autoload.php';
     18} else {
     19    // Handle missing autoloader
     20    error_log('SVGPlus: Composer autoloader not found. Please ensure dependencies are installed.');
     21    return;
     22}
    1723
    1824// Include the sanitizer class
    19 require_once plugin_dir_path(__FILE__) . 'includes/class-svgplus-sanitizer.php';
     25if (file_exists(plugin_dir_path(__FILE__) . 'includes/class-svgplus-sanitizer.php')) {
     26    require_once plugin_dir_path(__FILE__) . 'includes/class-svgplus-sanitizer.php';
     27} else {
     28    error_log('SVGPlus: Sanitizer class file not found.');
     29    return;
     30}
    2031
    2132// Plugin activation hook to set default settings
  • svgplus/trunk/vendor/autoload.php

    r3165214 r3165222  
    33// autoload.php @generated by Composer
    44
    5 if (PHP_VERSION_ID < 50600) {
    6     if (!headers_sent()) {
    7         header('HTTP/1.1 500 Internal Server Error');
    8     }
    9     $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
    10     if (!ini_get('display_errors')) {
    11         if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
    12             fwrite(STDERR, $err);
    13         } elseif (!headers_sent()) {
    14             echo $err;
    15         }
    16     }
    17     trigger_error(
    18         $err,
    19         E_USER_ERROR
    20     );
    21 }
    22 
    235require_once __DIR__ . '/composer/autoload_real.php';
    246
    25 return ComposerAutoloaderInit278afc54527d5abefe91adfc89b3adbf::getLoader();
     7return ComposerAutoloaderInit61c7f72a5d76a6a96ee3c8825ef2f87a::getLoader();
  • svgplus/trunk/vendor/composer/ClassLoader.php

    r3165214 r3165222  
    4343class ClassLoader
    4444{
    45     /** @var \Closure(string):void */
    46     private static $includeFile;
    47 
    48     /** @var string|null */
    49     private $vendorDir;
    50 
    5145    // PSR-4
    52     /**
    53      * @var array<string, array<string, int>>
    54      */
    5546    private $prefixLengthsPsr4 = array();
    56     /**
    57      * @var array<string, list<string>>
    58      */
    5947    private $prefixDirsPsr4 = array();
    60     /**
    61      * @var list<string>
    62      */
    6348    private $fallbackDirsPsr4 = array();
    6449
    6550    // PSR-0
    66     /**
    67      * List of PSR-0 prefixes
    68      *
    69      * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
    70      *
    71      * @var array<string, array<string, list<string>>>
    72      */
    7351    private $prefixesPsr0 = array();
    74     /**
    75      * @var list<string>
    76      */
    7752    private $fallbackDirsPsr0 = array();
    7853
    79     /** @var bool */
    8054    private $useIncludePath = false;
    81 
    82     /**
    83      * @var array<string, string>
    84      */
    8555    private $classMap = array();
    86 
    87     /** @var bool */
    8856    private $classMapAuthoritative = false;
    89 
    90     /**
    91      * @var array<string, bool>
    92      */
    9357    private $missingClasses = array();
    94 
    95     /** @var string|null */
    9658    private $apcuPrefix;
    9759
    98     /**
    99      * @var array<string, self>
    100      */
    101     private static $registeredLoaders = array();
    102 
    103     /**
    104      * @param string|null $vendorDir
    105      */
    106     public function __construct($vendorDir = null)
    107     {
    108         $this->vendorDir = $vendorDir;
    109         self::initializeIncludeClosure();
    110     }
    111 
    112     /**
    113      * @return array<string, list<string>>
    114      */
    11560    public function getPrefixes()
    11661    {
     
    12267    }
    12368
    124     /**
    125      * @return array<string, list<string>>
    126      */
    12769    public function getPrefixesPsr4()
    12870    {
     
    13072    }
    13173
    132     /**
    133      * @return list<string>
    134      */
    13574    public function getFallbackDirs()
    13675    {
     
    13877    }
    13978
    140     /**
    141      * @return list<string>
    142      */
    14379    public function getFallbackDirsPsr4()
    14480    {
     
    14682    }
    14783
    148     /**
    149      * @return array<string, string> Array of classname => path
    150      */
    15184    public function getClassMap()
    15285    {
     
    15588
    15689    /**
    157      * @param array<string, string> $classMap Class to filename map
    158      *
    159      * @return void
     90     * @param array $classMap Class to filename map
    16091     */
    16192    public function addClassMap(array $classMap)
     
    172103     * appending or prepending to the ones previously set for this prefix.
    173104     *
    174      * @param string              $prefix  The prefix
    175      * @param list<string>|string $paths   The PSR-0 root directories
    176      * @param bool                $prepend Whether to prepend the directories
    177      *
    178      * @return void
     105     * @param string       $prefix  The prefix
     106     * @param array|string $paths   The PSR-0 root directories
     107     * @param bool         $prepend Whether to prepend the directories
    179108     */
    180109    public function add($prefix, $paths, $prepend = false)
    181110    {
    182         $paths = (array) $paths;
    183111        if (!$prefix) {
    184112            if ($prepend) {
    185113                $this->fallbackDirsPsr0 = array_merge(
    186                     $paths,
     114                    (array) $paths,
    187115                    $this->fallbackDirsPsr0
    188116                );
     
    190118                $this->fallbackDirsPsr0 = array_merge(
    191119                    $this->fallbackDirsPsr0,
    192                     $paths
     120                    (array) $paths
    193121                );
    194122            }
     
    199127        $first = $prefix[0];
    200128        if (!isset($this->prefixesPsr0[$first][$prefix])) {
    201             $this->prefixesPsr0[$first][$prefix] = $paths;
     129            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
    202130
    203131            return;
     
    205133        if ($prepend) {
    206134            $this->prefixesPsr0[$first][$prefix] = array_merge(
    207                 $paths,
     135                (array) $paths,
    208136                $this->prefixesPsr0[$first][$prefix]
    209137            );
     
    211139            $this->prefixesPsr0[$first][$prefix] = array_merge(
    212140                $this->prefixesPsr0[$first][$prefix],
    213                 $paths
     141                (array) $paths
    214142            );
    215143        }
     
    220148     * appending or prepending to the ones previously set for this namespace.
    221149     *
    222      * @param string              $prefix  The prefix/namespace, with trailing '\\'
    223      * @param list<string>|string $paths   The PSR-4 base directories
    224      * @param bool                $prepend Whether to prepend the directories
     150     * @param string       $prefix  The prefix/namespace, with trailing '\\'
     151     * @param array|string $paths   The PSR-4 base directories
     152     * @param bool         $prepend Whether to prepend the directories
    225153     *
    226154     * @throws \InvalidArgumentException
    227      *
    228      * @return void
    229155     */
    230156    public function addPsr4($prefix, $paths, $prepend = false)
    231157    {
    232         $paths = (array) $paths;
    233158        if (!$prefix) {
    234159            // Register directories for the root namespace.
    235160            if ($prepend) {
    236161                $this->fallbackDirsPsr4 = array_merge(
    237                     $paths,
     162                    (array) $paths,
    238163                    $this->fallbackDirsPsr4
    239164                );
     
    241166                $this->fallbackDirsPsr4 = array_merge(
    242167                    $this->fallbackDirsPsr4,
    243                     $paths
     168                    (array) $paths
    244169                );
    245170            }
     
    251176            }
    252177            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    253             $this->prefixDirsPsr4[$prefix] = $paths;
     178            $this->prefixDirsPsr4[$prefix] = (array) $paths;
    254179        } elseif ($prepend) {
    255180            // Prepend directories for an already registered namespace.
    256181            $this->prefixDirsPsr4[$prefix] = array_merge(
    257                 $paths,
     182                (array) $paths,
    258183                $this->prefixDirsPsr4[$prefix]
    259184            );
     
    262187            $this->prefixDirsPsr4[$prefix] = array_merge(
    263188                $this->prefixDirsPsr4[$prefix],
    264                 $paths
     189                (array) $paths
    265190            );
    266191        }
     
    271196     * replacing any others previously set for this prefix.
    272197     *
    273      * @param string              $prefix The prefix
    274      * @param list<string>|string $paths  The PSR-0 base directories
    275      *
    276      * @return void
     198     * @param string       $prefix The prefix
     199     * @param array|string $paths  The PSR-0 base directories
    277200     */
    278201    public function set($prefix, $paths)
     
    289212     * replacing any others previously set for this namespace.
    290213     *
    291      * @param string              $prefix The prefix/namespace, with trailing '\\'
    292      * @param list<string>|string $paths  The PSR-4 base directories
     214     * @param string       $prefix The prefix/namespace, with trailing '\\'
     215     * @param array|string $paths  The PSR-4 base directories
    293216     *
    294217     * @throws \InvalidArgumentException
    295      *
    296      * @return void
    297218     */
    298219    public function setPsr4($prefix, $paths)
     
    314235     *
    315236     * @param bool $useIncludePath
    316      *
    317      * @return void
    318237     */
    319238    public function setUseIncludePath($useIncludePath)
     
    338257     *
    339258     * @param bool $classMapAuthoritative
    340      *
    341      * @return void
    342259     */
    343260    public function setClassMapAuthoritative($classMapAuthoritative)
     
    360277     *
    361278     * @param string|null $apcuPrefix
    362      *
    363      * @return void
    364279     */
    365280    public function setApcuPrefix($apcuPrefix)
     
    382297     *
    383298     * @param bool $prepend Whether to prepend the autoloader or not
    384      *
    385      * @return void
    386299     */
    387300    public function register($prepend = false)
    388301    {
    389302        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
    390 
    391         if (null === $this->vendorDir) {
    392             return;
    393         }
    394 
    395         if ($prepend) {
    396             self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
    397         } else {
    398             unset(self::$registeredLoaders[$this->vendorDir]);
    399             self::$registeredLoaders[$this->vendorDir] = $this;
    400         }
    401303    }
    402304
    403305    /**
    404306     * Unregisters this instance as an autoloader.
    405      *
    406      * @return void
    407307     */
    408308    public function unregister()
    409309    {
    410310        spl_autoload_unregister(array($this, 'loadClass'));
    411 
    412         if (null !== $this->vendorDir) {
    413             unset(self::$registeredLoaders[$this->vendorDir]);
    414         }
    415311    }
    416312
     
    419315     *
    420316     * @param  string    $class The name of the class
    421      * @return true|null True if loaded, null otherwise
     317     * @return bool|null True if loaded, null otherwise
    422318     */
    423319    public function loadClass($class)
    424320    {
    425321        if ($file = $this->findFile($class)) {
    426             $includeFile = self::$includeFile;
    427             $includeFile($file);
     322            includeFile($file);
    428323
    429324            return true;
    430325        }
    431 
    432         return null;
    433326    }
    434327
     
    475368    }
    476369
    477     /**
    478      * Returns the currently registered loaders keyed by their corresponding vendor directories.
    479      *
    480      * @return array<string, self>
    481      */
    482     public static function getRegisteredLoaders()
    483     {
    484         return self::$registeredLoaders;
    485     }
    486 
    487     /**
    488      * @param  string       $class
    489      * @param  string       $ext
    490      * @return string|false
    491      */
    492370    private function findFileWithExtension($class, $ext)
    493371    {
     
    555433        return false;
    556434    }
    557 
    558     /**
    559      * @return void
    560      */
    561     private static function initializeIncludeClosure()
    562     {
    563         if (self::$includeFile !== null) {
    564             return;
    565         }
    566 
    567         /**
    568          * Scope isolated include.
    569          *
    570          * Prevents access to $this/self from included files.
    571          *
    572          * @param  string $file
    573          * @return void
    574          */
    575         self::$includeFile = \Closure::bind(static function($file) {
    576             include $file;
    577         }, null, null);
    578     }
    579435}
     436
     437/**
     438 * Scope isolated include.
     439 *
     440 * Prevents access to $this/self from included files.
     441 */
     442function includeFile($file)
     443{
     444    include $file;
     445}
  • svgplus/trunk/vendor/composer/InstalledVersions.php

    r3165214 r3165222  
    11<?php
    22
    3 /*
    4  * This file is part of Composer.
    5  *
    6  * (c) Nils Adermann <[email protected]>
    7  *     Jordi Boggiano <[email protected]>
    8  *
    9  * For the full copyright and license information, please view the LICENSE
    10  * file that was distributed with this source code.
    11  */
     3
     4
     5
     6
     7
     8
     9
     10
     11
    1212
    1313namespace Composer;
    1414
    15 use Composer\Autoload\ClassLoader;
    1615use Composer\Semver\VersionParser;
    1716
    18 /**
    19  * This class is copied in every Composer installed project and available to all
    20  *
    21  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
    22  *
    23  * To require its presence, you can require `composer-runtime-api ^2.0`
    24  *
    25  * @final
    26  */
     17
     18
     19
     20
     21
    2722class InstalledVersions
    2823{
    29     /**
    30      * @var mixed[]|null
    31      * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
    32      */
    33     private static $installed;
    34 
    35     /**
    36      * @var bool|null
    37      */
    38     private static $canGetVendors;
    39 
    40     /**
    41      * @var array[]
    42      * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
    43      */
    44     private static $installedByVendor = array();
    45 
    46     /**
    47      * Returns a list of all package names which are present, either by being installed, replaced or provided
    48      *
    49      * @return string[]
    50      * @psalm-return list<string>
    51      */
    52     public static function getInstalledPackages()
    53     {
    54         $packages = array();
    55         foreach (self::getInstalled() as $installed) {
    56             $packages[] = array_keys($installed['versions']);
    57         }
    58 
    59         if (1 === \count($packages)) {
    60             return $packages[0];
    61         }
    62 
    63         return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
    64     }
    65 
    66     /**
    67      * Returns a list of all package names with a specific type e.g. 'library'
    68      *
    69      * @param  string   $type
    70      * @return string[]
    71      * @psalm-return list<string>
    72      */
    73     public static function getInstalledPackagesByType($type)
    74     {
    75         $packagesByType = array();
    76 
    77         foreach (self::getInstalled() as $installed) {
    78             foreach ($installed['versions'] as $name => $package) {
    79                 if (isset($package['type']) && $package['type'] === $type) {
    80                     $packagesByType[] = $name;
    81                 }
    82             }
    83         }
    84 
    85         return $packagesByType;
    86     }
    87 
    88     /**
    89      * Checks whether the given package is installed
    90      *
    91      * This also returns true if the package name is provided or replaced by another package
    92      *
    93      * @param  string $packageName
    94      * @param  bool   $includeDevRequirements
    95      * @return bool
    96      */
    97     public static function isInstalled($packageName, $includeDevRequirements = true)
    98     {
    99         foreach (self::getInstalled() as $installed) {
    100             if (isset($installed['versions'][$packageName])) {
    101                 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
    102             }
    103         }
    104 
    105         return false;
    106     }
    107 
    108     /**
    109      * Checks whether the given package satisfies a version constraint
    110      *
    111      * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
    112      *
    113      *   Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
    114      *
    115      * @param  VersionParser $parser      Install composer/semver to have access to this class and functionality
    116      * @param  string        $packageName
    117      * @param  string|null   $constraint  A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
    118      * @return bool
    119      */
    120     public static function satisfies(VersionParser $parser, $packageName, $constraint)
    121     {
    122         $constraint = $parser->parseConstraints((string) $constraint);
    123         $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
    124 
    125         return $provided->matches($constraint);
    126     }
    127 
    128     /**
    129      * Returns a version constraint representing all the range(s) which are installed for a given package
    130      *
    131      * It is easier to use this via isInstalled() with the $constraint argument if you need to check
    132      * whether a given version of a package is installed, and not just whether it exists
    133      *
    134      * @param  string $packageName
    135      * @return string Version constraint usable with composer/semver
    136      */
    137     public static function getVersionRanges($packageName)
    138     {
    139         foreach (self::getInstalled() as $installed) {
    140             if (!isset($installed['versions'][$packageName])) {
    141                 continue;
    142             }
    143 
    144             $ranges = array();
    145             if (isset($installed['versions'][$packageName]['pretty_version'])) {
    146                 $ranges[] = $installed['versions'][$packageName]['pretty_version'];
    147             }
    148             if (array_key_exists('aliases', $installed['versions'][$packageName])) {
    149                 $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
    150             }
    151             if (array_key_exists('replaced', $installed['versions'][$packageName])) {
    152                 $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
    153             }
    154             if (array_key_exists('provided', $installed['versions'][$packageName])) {
    155                 $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
    156             }
    157 
    158             return implode(' || ', $ranges);
    159         }
    160 
    161         throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    162     }
    163 
    164     /**
    165      * @param  string      $packageName
    166      * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
    167      */
    168     public static function getVersion($packageName)
    169     {
    170         foreach (self::getInstalled() as $installed) {
    171             if (!isset($installed['versions'][$packageName])) {
    172                 continue;
    173             }
    174 
    175             if (!isset($installed['versions'][$packageName]['version'])) {
    176                 return null;
    177             }
    178 
    179             return $installed['versions'][$packageName]['version'];
    180         }
    181 
    182         throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    183     }
    184 
    185     /**
    186      * @param  string      $packageName
    187      * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
    188      */
    189     public static function getPrettyVersion($packageName)
    190     {
    191         foreach (self::getInstalled() as $installed) {
    192             if (!isset($installed['versions'][$packageName])) {
    193                 continue;
    194             }
    195 
    196             if (!isset($installed['versions'][$packageName]['pretty_version'])) {
    197                 return null;
    198             }
    199 
    200             return $installed['versions'][$packageName]['pretty_version'];
    201         }
    202 
    203         throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    204     }
    205 
    206     /**
    207      * @param  string      $packageName
    208      * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
    209      */
    210     public static function getReference($packageName)
    211     {
    212         foreach (self::getInstalled() as $installed) {
    213             if (!isset($installed['versions'][$packageName])) {
    214                 continue;
    215             }
    216 
    217             if (!isset($installed['versions'][$packageName]['reference'])) {
    218                 return null;
    219             }
    220 
    221             return $installed['versions'][$packageName]['reference'];
    222         }
    223 
    224         throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    225     }
    226 
    227     /**
    228      * @param  string      $packageName
    229      * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
    230      */
    231     public static function getInstallPath($packageName)
    232     {
    233         foreach (self::getInstalled() as $installed) {
    234             if (!isset($installed['versions'][$packageName])) {
    235                 continue;
    236             }
    237 
    238             return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
    239         }
    240 
    241         throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    242     }
    243 
    244     /**
    245      * @return array
    246      * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
    247      */
    248     public static function getRootPackage()
    249     {
    250         $installed = self::getInstalled();
    251 
    252         return $installed[0]['root'];
    253     }
    254 
    255     /**
    256      * Returns the raw installed.php data for custom implementations
    257      *
    258      * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
    259      * @return array[]
    260      * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
    261      */
    262     public static function getRawData()
    263     {
    264         @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
    265 
    266         if (null === self::$installed) {
    267             // only require the installed.php file if this file is loaded from its dumped location,
    268             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
    269             if (substr(__DIR__, -8, 1) !== 'C') {
    270                 self::$installed = include __DIR__ . '/installed.php';
    271             } else {
    272                 self::$installed = array();
    273             }
    274         }
    275 
    276         return self::$installed;
    277     }
    278 
    279     /**
    280      * Returns the raw data of all installed.php which are currently loaded for custom implementations
    281      *
    282      * @return array[]
    283      * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
    284      */
    285     public static function getAllRawData()
    286     {
    287         return self::getInstalled();
    288     }
    289 
    290     /**
    291      * Lets you reload the static array from another file
    292      *
    293      * This is only useful for complex integrations in which a project needs to use
    294      * this class but then also needs to execute another project's autoloader in process,
    295      * and wants to ensure both projects have access to their version of installed.php.
    296      *
    297      * A typical case would be PHPUnit, where it would need to make sure it reads all
    298      * the data it needs from this class, then call reload() with
    299      * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
    300      * the project in which it runs can then also use this class safely, without
    301      * interference between PHPUnit's dependencies and the project's dependencies.
    302      *
    303      * @param  array[] $data A vendor/composer/installed.php data set
    304      * @return void
    305      *
    306      * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
    307      */
    308     public static function reload($data)
    309     {
    310         self::$installed = $data;
    311         self::$installedByVendor = array();
    312     }
    313 
    314     /**
    315      * @return array[]
    316      * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
    317      */
    318     private static function getInstalled()
    319     {
    320         if (null === self::$canGetVendors) {
    321             self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
    322         }
    323 
    324         $installed = array();
    325 
    326         if (self::$canGetVendors) {
    327             foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
    328                 if (isset(self::$installedByVendor[$vendorDir])) {
    329                     $installed[] = self::$installedByVendor[$vendorDir];
    330                 } elseif (is_file($vendorDir.'/composer/installed.php')) {
    331                     /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332                     $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
    336                     }
    337                 }
    338             }
    339         }
    340 
    341         if (null === self::$installed) {
    342             // only require the installed.php file if this file is loaded from its dumped location,
    343             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
    344             if (substr(__DIR__, -8, 1) !== 'C') {
    345                 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    346                 $required = require __DIR__ . '/installed.php';
    347                 self::$installed = $required;
    348             } else {
    349                 self::$installed = array();
    350             }
    351         }
    352 
    353         if (self::$installed !== array()) {
    354             $installed[] = self::$installed;
    355         }
    356 
    357         return $installed;
    358     }
    359 }
     24private static $installed = array (
     25  'root' =>
     26  array (
     27    'pretty_version' => '1.0.0+no-version-set',
     28    'version' => '1.0.0.0',
     29    'aliases' =>
     30    array (
     31    ),
     32    'reference' => NULL,
     33    'name' => '__root__',
     34  ),
     35  'versions' =>
     36  array (
     37    '__root__' =>
     38    array (
     39      'pretty_version' => '1.0.0+no-version-set',
     40      'version' => '1.0.0.0',
     41      'aliases' =>
     42      array (
     43      ),
     44      'reference' => NULL,
     45    ),
     46    'enshrined/svg-sanitize' =>
     47    array (
     48      'pretty_version' => '0.14.1',
     49      'version' => '0.14.1.0',
     50      'aliases' =>
     51      array (
     52      ),
     53      'reference' => '307b42066fb0b76b5119f5e1f0826e18fefabe95',
     54    ),
     55  ),
     56);
     57
     58
     59
     60
     61
     62
     63
     64public static function getInstalledPackages()
     65{
     66return array_keys(self::$installed['versions']);
     67}
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77public static function isInstalled($packageName)
     78{
     79return isset(self::$installed['versions'][$packageName]);
     80}
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95public static function satisfies(VersionParser $parser, $packageName, $constraint)
     96{
     97$constraint = $parser->parseConstraints($constraint);
     98$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
     99
     100return $provided->matches($constraint);
     101}
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112public static function getVersionRanges($packageName)
     113{
     114if (!isset(self::$installed['versions'][$packageName])) {
     115throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     116}
     117
     118$ranges = array();
     119if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
     120$ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
     121}
     122if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
     123$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
     124}
     125if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
     126$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
     127}
     128if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
     129$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
     130}
     131
     132return implode(' || ', $ranges);
     133}
     134
     135
     136
     137
     138
     139public static function getVersion($packageName)
     140{
     141if (!isset(self::$installed['versions'][$packageName])) {
     142throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     143}
     144
     145if (!isset(self::$installed['versions'][$packageName]['version'])) {
     146return null;
     147}
     148
     149return self::$installed['versions'][$packageName]['version'];
     150}
     151
     152
     153
     154
     155
     156public static function getPrettyVersion($packageName)
     157{
     158if (!isset(self::$installed['versions'][$packageName])) {
     159throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     160}
     161
     162if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
     163return null;
     164}
     165
     166return self::$installed['versions'][$packageName]['pretty_version'];
     167}
     168
     169
     170
     171
     172
     173public static function getReference($packageName)
     174{
     175if (!isset(self::$installed['versions'][$packageName])) {
     176throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     177}
     178
     179if (!isset(self::$installed['versions'][$packageName]['reference'])) {
     180return null;
     181}
     182
     183return self::$installed['versions'][$packageName]['reference'];
     184}
     185
     186
     187
     188
     189
     190public static function getRootPackage()
     191{
     192return self::$installed['root'];
     193}
     194
     195
     196
     197
     198
     199
     200
     201public static function getRawData()
     202{
     203return self::$installed;
     204}
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224public static function reload($data)
     225{
     226self::$installed = $data;
     227}
     228}
  • svgplus/trunk/vendor/composer/autoload_classmap.php

    r3165214 r3165222  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(__DIR__);
     5$vendorDir = dirname(dirname(__FILE__));
    66$baseDir = dirname($vendorDir);
    77
  • svgplus/trunk/vendor/composer/autoload_namespaces.php

    r3165214 r3165222  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(__DIR__);
     5$vendorDir = dirname(dirname(__FILE__));
    66$baseDir = dirname($vendorDir);
    77
  • svgplus/trunk/vendor/composer/autoload_psr4.php

    r3165214 r3165222  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(__DIR__);
     5$vendorDir = dirname(dirname(__FILE__));
    66$baseDir = dirname($vendorDir);
    77
  • svgplus/trunk/vendor/composer/autoload_real.php

    r3165214 r3165222  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit278afc54527d5abefe91adfc89b3adbf
     5class ComposerAutoloaderInit61c7f72a5d76a6a96ee3c8825ef2f87a
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit278afc54527d5abefe91adfc89b3adbf', 'loadClassLoader'), true, true);
    28         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit278afc54527d5abefe91adfc89b3adbf', 'loadClassLoader'));
     27        spl_autoload_register(array('ComposerAutoloaderInit61c7f72a5d76a6a96ee3c8825ef2f87a', 'loadClassLoader'), true, true);
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     29        spl_autoload_unregister(array('ComposerAutoloaderInit61c7f72a5d76a6a96ee3c8825ef2f87a', 'loadClassLoader'));
    3030
    31         require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit278afc54527d5abefe91adfc89b3adbf::getInitializer($loader));
     31        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     32        if ($useStaticLoader) {
     33            require __DIR__ . '/autoload_static.php';
     34
     35            call_user_func(\Composer\Autoload\ComposerStaticInit61c7f72a5d76a6a96ee3c8825ef2f87a::getInitializer($loader));
     36        } else {
     37            $map = require __DIR__ . '/autoload_namespaces.php';
     38            foreach ($map as $namespace => $path) {
     39                $loader->set($namespace, $path);
     40            }
     41
     42            $map = require __DIR__ . '/autoload_psr4.php';
     43            foreach ($map as $namespace => $path) {
     44                $loader->setPsr4($namespace, $path);
     45            }
     46
     47            $classMap = require __DIR__ . '/autoload_classmap.php';
     48            if ($classMap) {
     49                $loader->addClassMap($classMap);
     50            }
     51        }
    3352
    3453        $loader->register(true);
  • svgplus/trunk/vendor/composer/autoload_static.php

    r3165214 r3165222  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit278afc54527d5abefe91adfc89b3adbf
     7class ComposerStaticInit61c7f72a5d76a6a96ee3c8825ef2f87a
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    2828    {
    2929        return \Closure::bind(function () use ($loader) {
    30             $loader->prefixLengthsPsr4 = ComposerStaticInit278afc54527d5abefe91adfc89b3adbf::$prefixLengthsPsr4;
    31             $loader->prefixDirsPsr4 = ComposerStaticInit278afc54527d5abefe91adfc89b3adbf::$prefixDirsPsr4;
    32             $loader->classMap = ComposerStaticInit278afc54527d5abefe91adfc89b3adbf::$classMap;
     30            $loader->prefixLengthsPsr4 = ComposerStaticInit61c7f72a5d76a6a96ee3c8825ef2f87a::$prefixLengthsPsr4;
     31            $loader->prefixDirsPsr4 = ComposerStaticInit61c7f72a5d76a6a96ee3c8825ef2f87a::$prefixDirsPsr4;
     32            $loader->classMap = ComposerStaticInit61c7f72a5d76a6a96ee3c8825ef2f87a::$classMap;
    3333
    3434        }, null, ClassLoader::class);
  • svgplus/trunk/vendor/composer/installed.json

    r3165214 r3165222  
    33        {
    44            "name": "enshrined/svg-sanitize",
    5             "version": "0.20.0",
    6             "version_normalized": "0.20.0.0",
     5            "version": "0.14.1",
     6            "version_normalized": "0.14.1.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/darylldoyle/svg-sanitizer.git",
    10                 "reference": "068d9fcf912c88a0471d101d95a2caa87c50aee7"
     10                "reference": "307b42066fb0b76b5119f5e1f0826e18fefabe95"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/068d9fcf912c88a0471d101d95a2caa87c50aee7",
    15                 "reference": "068d9fcf912c88a0471d101d95a2caa87c50aee7",
     14                "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/307b42066fb0b76b5119f5e1f0826e18fefabe95",
     15                "reference": "307b42066fb0b76b5119f5e1f0826e18fefabe95",
    1616                "shasum": ""
    1717            },
     
    1919                "ext-dom": "*",
    2020                "ext-libxml": "*",
    21                 "php": "^7.1 || ^8.0"
     21                "php": "^7.0 || ^8.0"
    2222            },
    2323            "require-dev": {
     24                "codeclimate/php-test-reporter": "^0.1.2",
    2425                "phpunit/phpunit": "^6.5 || ^8.5"
    2526            },
    26             "time": "2024-09-05T10:18:12+00:00",
     27            "time": "2021-08-09T23:46:54+00:00",
    2728            "type": "library",
    2829            "installation-source": "dist",
     
    4546            "support": {
    4647                "issues": "https://github.com/darylldoyle/svg-sanitizer/issues",
    47                 "source": "https://github.com/darylldoyle/svg-sanitizer/tree/0.20.0"
     48                "source": "https://github.com/darylldoyle/svg-sanitizer/tree/0.14.1"
    4849            },
    4950            "install-path": "../enshrined/svg-sanitize"
  • svgplus/trunk/vendor/composer/installed.php

    r3165214 r3165222  
    1 <?php return array(
    2     'root' => array(
    3         'name' => 'derickpayne/svgplus',
    4         'pretty_version' => '1.0.0+no-version-set',
    5         'version' => '1.0.0.0',
    6         'reference' => null,
    7         'type' => 'library',
    8         'install_path' => __DIR__ . '/../../',
    9         'aliases' => array(),
    10         'dev' => true,
     1<?php return array (
     2  'root' =>
     3  array (
     4    'pretty_version' => '1.0.0+no-version-set',
     5    'version' => '1.0.0.0',
     6    'aliases' =>
     7    array (
    118    ),
    12     'versions' => array(
    13         'derickpayne/svgplus' => array(
    14             'pretty_version' => '1.0.0+no-version-set',
    15             'version' => '1.0.0.0',
    16             'reference' => null,
    17             'type' => 'library',
    18             'install_path' => __DIR__ . '/../../',
    19             'aliases' => array(),
    20             'dev_requirement' => false,
    21         ),
    22         'enshrined/svg-sanitize' => array(
    23             'pretty_version' => '0.20.0',
    24             'version' => '0.20.0.0',
    25             'reference' => '068d9fcf912c88a0471d101d95a2caa87c50aee7',
    26             'type' => 'library',
    27             'install_path' => __DIR__ . '/../enshrined/svg-sanitize',
    28             'aliases' => array(),
    29             'dev_requirement' => false,
    30         ),
     9    'reference' => NULL,
     10    'name' => '__root__',
     11  ),
     12  'versions' =>
     13  array (
     14    '__root__' =>
     15    array (
     16      'pretty_version' => '1.0.0+no-version-set',
     17      'version' => '1.0.0.0',
     18      'aliases' =>
     19      array (
     20      ),
     21      'reference' => NULL,
    3122    ),
     23    'enshrined/svg-sanitize' =>
     24    array (
     25      'pretty_version' => '0.14.1',
     26      'version' => '0.14.1.0',
     27      'aliases' =>
     28      array (
     29      ),
     30      'reference' => '307b42066fb0b76b5119f5e1f0826e18fefabe95',
     31    ),
     32  ),
    3233);
  • svgplus/trunk/vendor/composer/platform_check.php

    r3165214 r3165222  
    55$issues = array();
    66
    7 if (!(PHP_VERSION_ID >= 70100)) {
    8     $issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.0". You are running ' . PHP_VERSION . '.';
     7if (!(PHP_VERSION_ID >= 50600)) {
     8    $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
    99}
    1010
  • svgplus/trunk/vendor/enshrined/svg-sanitize/README.md

    r3165214 r3165222  
    11# svg-sanitizer
    22
    3 [![Build Status](https://github.com/darylldoyle/svg-sanitizer/actions/workflows/tests.yml/badge.svg?branch=master)](https://travis-ci.org/darylldoyle/svg-sanitizer) [![Test Coverage](https://codeclimate.com/github/darylldoyle/svg-sanitizer/badges/coverage.svg)](https://codeclimate.com/github/darylldoyle/svg-sanitizer/coverage)
     3[![Build Status](https://travis-ci.org/darylldoyle/svg-sanitizer.svg?branch=master)](https://travis-ci.org/darylldoyle/svg-sanitizer) [![Test Coverage](https://codeclimate.com/github/darylldoyle/svg-sanitizer/badges/coverage.svg)](https://codeclimate.com/github/darylldoyle/svg-sanitizer/coverage)
    44
    5 This is my attempt at building a decent SVG sanitizer in PHP. The work is largely borrowed from [DOMPurify](https://github.com/cure53/DOMPurify).
     5This is my attempt at building a decent SVG sanitizer in PHP. The work is laregely borrowed from [DOMPurify](https://github.com/cure53/DOMPurify).
    66
    77## Installation
     
    4141These methods require that you implement the `enshrined\svgSanitize\data\TagInterface` or `enshrined\svgSanitize\data\AttributeInterface`.
    4242
    43 ## Remove remote references
     43## Remove remote references 
    4444
    4545You have the option to remove attributes that reference remote files, this will stop HTTP leaks but will add an overhead to the sanitizer.
     
    7474## TYPO3
    7575
    76 This SVG sanitizer library is used per default in the core of TYPO3 v9 and later versions.
    77 See [corresponding changelog entry](https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.5.x/Important-94492-IntroduceSVGSanitizer.html) for more details.
     76An integration for TYPO3 CMS of this library is available as composer package `t3g/svg-sanitizer` at [https://github.com/TYPO3GmbH/svg_sanitizer](https://github.com/TYPO3GmbH/svg_sanitizer)
    7877
    7978## Tests
  • svgplus/trunk/vendor/enshrined/svg-sanitize/composer.json

    r3165214 r3165222  
    1010    ],
    1111    "scripts": {
    12         "test": "phpunit --no-coverage",
    13         "test:coverage": "phpunit"
     12        "test": "phpunit --no-coverage"
    1413    },
    1514    "autoload": {
     
    2625        "ext-dom": "*",
    2726        "ext-libxml": "*",
    28         "php": "^7.1 || ^8.0"
     27        "php": "^7.0 || ^8.0"
    2928    },
    3029    "require-dev": {
    31         "phpunit/phpunit": "^6.5 || ^8.5"
     30        "phpunit/phpunit": "^6.5 || ^8.5",
     31        "codeclimate/php-test-reporter": "^0.1.2"
    3232    }
    3333}
  • svgplus/trunk/vendor/enshrined/svg-sanitize/src/Exceptions/NestingException.php

    r3165214 r3165222  
    11<?php
     2
     3
    24namespace enshrined\svgSanitize\Exceptions;
     5
    36
    47use Exception;
     
    1922     * @param \DOMElement|null $element
    2023     */
    21     public function __construct($message = "", $code = 0, ?Exception $previous = null, ?\DOMElement $element = null)
     24    public function __construct($message = "", $code = 0, Exception $previous = null, \DOMElement $element = null)
    2225    {
    2326        $this->element = $element;
  • svgplus/trunk/vendor/enshrined/svg-sanitize/src/Sanitizer.php

    r3165214 r3165222  
    11<?php
     2
    23namespace enshrined\svgSanitize;
    34
     
    89use enshrined\svgSanitize\data\XPath;
    910use enshrined\svgSanitize\ElementReference\Resolver;
     11use enshrined\svgSanitize\ElementReference\Subject;
    1012
    1113/**
     
    4042     * @var bool
    4143     */
    42     protected $xmlErrorHandlerPreviousValue;
     44    protected $minifyXML = false;
    4345
    4446    /**
    4547     * @var bool
    4648     */
    47     protected $minifyXML = false;
     49    protected $removeRemoteReferences = false;
     50
     51    /**
     52     * @var int
     53     */
     54    protected $useThreshold = 1000;
    4855
    4956    /**
    5057     * @var bool
    5158     */
    52     protected $removeRemoteReferences = false;
     59    protected $removeXMLTag = false;
    5360
    5461    /**
    5562     * @var int
    5663     */
    57     protected $useThreshold = 1000;
    58 
    59     /**
    60      * @var bool
    61      */
    62     protected $removeXMLTag = false;
     64    protected $xmlOptions = LIBXML_NOEMPTYTAG;
     65
     66    /**
     67     * @var array
     68     */
     69    protected $xmlIssues = array();
     70
     71    /**
     72     * @var Resolver
     73     */
     74    protected $elementReferenceResolver;
    6375
    6476    /**
    6577     * @var int
    6678     */
    67     protected $xmlOptions = LIBXML_NOEMPTYTAG;
    68 
    69     /**
    70      * @var array
    71      */
    72     protected $xmlIssues = array();
    73 
    74     /**
    75      * @var Resolver
    76      */
    77     protected $elementReferenceResolver;
    78 
    79     /**
    80      * @var int
    81      */
    8279    protected $useNestingLimit = 15;
    83 
    84     /**
    85      * @var bool
    86      */
    87     protected $allowHugeFiles = false;
    8880
    8981    /**
     
    189181    }
    190182
    191     /**
    192      * Can we allow huge files?
    193      *
    194      * @return bool
    195      */
    196     public function getAllowHugeFiles() {
    197         return $this->allowHugeFiles;
    198     }
    199 
    200     /**
    201      * Set whether we can allow huge files.
    202      *
    203      * @param bool $allowHugeFiles
    204      */
    205     public function setAllowHugeFiles( $allowHugeFiles ) {
    206         $this->allowHugeFiles = $allowHugeFiles;
    207     }
    208 
    209183
    210184    /**
     
    212186     *
    213187     * @param string $dirty
    214      * @return string|false
     188     * @return string
    215189     */
    216190    public function sanitize($dirty)
     
    221195        }
    222196
    223         do {
    224             /*
    225              * recursively remove php tags because they can be hidden inside tags
    226              * i.e. <?p<?php test?>hp echo . ' danger! ';?>
    227              */
    228             $dirty = preg_replace('/<\?(=|php)(.+?)\?>/i', '', $dirty);
    229         } while (preg_match('/<\?(=|php)(.+?)\?>/i', $dirty) != 0);
     197        // Strip php tags
     198        $dirty = preg_replace('/<\?(=|php)(.+?)\?>/i', '', $dirty);
    230199
    231200        $this->resetInternal();
    232201        $this->setUpBefore();
    233202
    234         $loaded = $this->xmlDocument->loadXML($dirty, $this->getAllowHugeFiles() ? LIBXML_PARSEHUGE : 0);
     203        $loaded = $this->xmlDocument->loadXML($dirty);
    235204
    236205        // If we couldn't parse the XML then we go no further. Reset and return false
    237206        if (!$loaded) {
    238             $this->xmlIssues = self::getXmlErrors();
    239207            $this->resetAfter();
    240208            return false;
     
    247215        $elementsToRemove = $this->elementReferenceResolver->getElementsToRemove();
    248216
    249         // Start the cleaning process
    250         $this->startClean($this->xmlDocument->childNodes, $elementsToRemove);
     217        // Grab all the elements
     218        $allElements = $this->xmlDocument->getElementsByTagName("*");
     219
     220        // remove doctype after node elements have been analyzed
     221        $this->removeDoctype();
     222        // Start the cleaning proccess
     223        $this->startClean($allElements, $elementsToRemove);
    251224
    252225        // Save cleaned XML to a variable
     
    280253        }
    281254
    282         // Suppress the errors because we don't really have to worry about formation before cleansing.
    283         // See reset in resetAfter().
    284         $this->xmlErrorHandlerPreviousValue = libxml_use_internal_errors(true);
     255        // Suppress the errors because we don't really have to worry about formation before cleansing
     256        libxml_use_internal_errors(true);
    285257
    286258        // Reset array of altered XML
     
    299271            libxml_disable_entity_loader($this->xmlLoaderValue);
    300272        }
    301 
    302         libxml_clear_errors();
    303         libxml_use_internal_errors($this->xmlErrorHandlerPreviousValue);
     273    }
     274
     275    /**
     276     * Remove the XML Doctype
     277     * It may be caught later on output but that seems to be buggy, so we need to make sure it's gone
     278     */
     279    protected function removeDoctype()
     280    {
     281        foreach ($this->xmlDocument->childNodes as $child) {
     282            if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
     283                $child->parentNode->removeChild($child);
     284            }
     285        }
    304286    }
    305287
     
    335317            }
    336318
    337             if ($currentElement instanceof \DOMElement) {
    338                 // If the tag isn't in the whitelist, remove it and continue with next iteration
    339                 if (!in_array(strtolower($currentElement->tagName), $this->allowedTags)) {
     319            // If the tag isn't in the whitelist, remove it and continue with next iteration
     320            if (!in_array(strtolower($currentElement->tagName), $this->allowedTags)) {
     321                $currentElement->parentNode->removeChild($currentElement);
     322                $this->xmlIssues[] = array(
     323                    'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
     324                    'line' => $currentElement->getLineNo(),
     325                );
     326                continue;
     327            }
     328
     329            $this->cleanHrefs($currentElement);
     330
     331            $this->cleanXlinkHrefs($currentElement);
     332
     333            $this->cleanAttributesOnWhitelist($currentElement);
     334
     335            if (strtolower($currentElement->tagName) === 'use') {
     336                if ($this->isUseTagDirty($currentElement)
     337                    || $this->isUseTagExceedingThreshold($currentElement)
     338                ) {
    340339                    $currentElement->parentNode->removeChild($currentElement);
    341340                    $this->xmlIssues[] = array(
    342                         'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
     341                        'message' => 'Suspicious \'' . $currentElement->tagName . '\'',
    343342                        'line' => $currentElement->getLineNo(),
    344343                    );
    345344                    continue;
    346345                }
    347 
    348                 $this->cleanHrefs( $currentElement );
    349 
    350                 $this->cleanXlinkHrefs( $currentElement );
    351 
    352                 $this->cleanAttributesOnWhitelist($currentElement);
    353 
    354                 if (strtolower($currentElement->tagName) === 'use') {
    355                     if ($this->isUseTagDirty($currentElement)
    356                         || $this->isUseTagExceedingThreshold($currentElement)
    357                     ) {
    358                         $currentElement->parentNode->removeChild($currentElement);
    359                         $this->xmlIssues[] = array(
    360                             'message' => 'Suspicious \'' . $currentElement->tagName . '\'',
    361                             'line' => $currentElement->getLineNo(),
    362                         );
    363                         continue;
    364                     }
    365                 }
    366 
    367                 // Strip out font elements that will break out of foreign content.
    368                 if (strtolower($currentElement->tagName) === 'font') {
    369                     $breaksOutOfForeignContent = false;
    370                     for ($x = $currentElement->attributes->length - 1; $x >= 0; $x--) {
    371                         // get attribute name
    372                         $attrName = $currentElement->attributes->item( $x )->nodeName;
    373 
    374                         if (in_array(strtolower($attrName), ['face', 'color', 'size'])) {
    375                             $breaksOutOfForeignContent = true;
    376                         }
    377                     }
    378 
    379                     if ($breaksOutOfForeignContent) {
    380                         $currentElement->parentNode->removeChild($currentElement);
    381                         $this->xmlIssues[] = array(
    382                             'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
    383                             'line' => $currentElement->getLineNo(),
    384                         );
    385                         continue;
    386                     }
    387                 }
    388             }
    389 
    390             $this->cleanUnsafeNodes($currentElement);
    391 
    392             if ($currentElement->hasChildNodes()) {
    393                 $this->startClean($currentElement->childNodes, $elementsToRemove);
    394346            }
    395347        }
     
    405357        for ($x = $element->attributes->length - 1; $x >= 0; $x--) {
    406358            // get attribute name
    407             $attrName = $element->attributes->item($x)->nodeName;
     359            $attrName = $element->attributes->item($x)->name;
    408360
    409361            // Remove attribute if not in whitelist
     
    481433    }
    482434
    483     /**
    484      * Only allow whitelisted starts to be within the href.
    485      *
    486      * This will stop scripts etc from being passed through, with or without attempting to hide bypasses.
    487      * This stops the need for us to use a complicated script regex.
    488      *
    489      * @param $value
    490      * @return bool
    491      */
     435/**
     436 * Only allow whitelisted starts to be within the href.
     437 *
     438 * This will stop scripts etc from being passed through, with or without attempting to hide bypasses.
     439 * This stops the need for us to use a complicated script regex.
     440 *
     441 * @param $value
     442 * @return bool
     443 */
    492444    protected function isHrefSafeValue($value) {
    493445
     
    525477            'data:image/pjp', // PJPEG
    526478        ))) {
    527             return true;
     479           return true;
    528480        }
    529481
     
    676628        $this->useNestingLimit = (int) $limit;
    677629    }
    678 
    679     /**
    680      * Remove nodes that are either invalid or malformed.
    681      *
    682      * @param \DOMNode $currentElement The current element.
    683      */
    684     protected function cleanUnsafeNodes(\DOMNode $currentElement) {
    685         // Replace CDATA node with encoded text node
    686         if ($currentElement instanceof \DOMCdataSection) {
    687             $textNode = $currentElement->ownerDocument->createTextNode($currentElement->nodeValue);
    688             $currentElement->parentNode->replaceChild($textNode, $currentElement);
    689         // If the element doesn't have a tagname, remove it and continue with next iteration
    690         } elseif (!$currentElement instanceof \DOMElement && !$currentElement instanceof \DOMText) {
    691             $currentElement->parentNode->removeChild($currentElement);
    692             $this->xmlIssues[] = array(
    693                 'message' => 'Suspicious node \'' . $currentElement->nodeName . '\'',
    694                 'line' => $currentElement->getLineNo(),
    695             );
    696             return;
    697         }
    698 
    699         if ( $currentElement->childNodes && $currentElement->childNodes->length > 0 ) {
    700             for ($j = $currentElement->childNodes->length - 1; $j >= 0; $j--) {
    701                 /** @var \DOMElement $childElement */
    702                 $childElement = $currentElement->childNodes->item($j);
    703                 $this->cleanUnsafeNodes($childElement);
    704             }
    705         }
    706     }
    707 
    708     /**
    709      * Retrieve array of errors
    710      * @return array
    711      */
    712     private static function getXmlErrors()
    713     {
    714         $errors = [];
    715         foreach (libxml_get_errors() as $error) {
    716             $errors[] = [
    717                 'message' => trim($error->message),
    718                 'line' => $error->line,
    719             ];
    720         }
    721 
    722         return $errors;
    723     }
    724630}
  • svgplus/trunk/vendor/enshrined/svg-sanitize/src/data/AllowedAttributes.php

    r3165214 r3165222  
    11<?php
     2
     3
    24namespace enshrined\svgSanitize\data;
     5
    36
    47/**
     
    152155            'fill-rule',
    153156            'filter',
    154             'filterUnits',
    155157            'flood-color',
    156158            'flood-opacity',
     
    271273            'viewbox',
    272274            'visibility',
    273             'vector-effect',
    274275            'vert-adv-y',
    275276            'vert-origin-x',
  • svgplus/trunk/vendor/enshrined/svg-sanitize/src/data/AllowedTags.php

    r3165214 r3165222  
    11<?php
     2
     3
    24namespace enshrined\svgSanitize\data;
     5
    36
    47/**
     
    2023            // HTML
    2124            'a',
     25            'abbr',
     26            'acronym',
     27            'address',
     28            'area',
     29            'article',
     30            'aside',
     31            'audio',
     32            'b',
     33            'bdi',
     34            'bdo',
     35            'big',
     36            'blink',
     37            'blockquote',
     38            'body',
     39            'br',
     40            'button',
     41            'canvas',
     42            'caption',
     43            'center',
     44            'cite',
     45            'code',
     46            'col',
     47            'colgroup',
     48            'content',
     49            'data',
     50            'datalist',
     51            'dd',
     52            'decorator',
     53            'del',
     54            'details',
     55            'dfn',
     56            'dir',
     57            'div',
     58            'dl',
     59            'dt',
     60            'element',
     61            'em',
     62            'fieldset',
     63            'figcaption',
     64            'figure',
    2265            'font',
     66            'footer',
     67            'form',
     68            'h1',
     69            'h2',
     70            'h3',
     71            'h4',
     72            'h5',
     73            'h6',
     74            'head',
     75            'header',
     76            'hgroup',
     77            'hr',
     78            'html',
     79            'i',
    2380            'image',
     81            'img',
     82            'input',
     83            'ins',
     84            'kbd',
     85            'label',
     86            'legend',
     87            'li',
     88            'main',
     89            'map',
     90            'mark',
     91            'marquee',
     92            'menu',
     93            'menuitem',
     94            'meter',
     95            'nav',
     96            'nobr',
     97            'ol',
     98            'optgroup',
     99            'option',
     100            'output',
     101            'p',
     102            'pre',
     103            'progress',
     104            'q',
     105            'rp',
     106            'rt',
     107            'ruby',
     108            's',
     109            'samp',
     110            'section',
     111            'select',
     112            'shadow',
     113            'small',
     114            'source',
     115            'spacer',
     116            'span',
     117            'strike',
     118            'strong',
    24119            'style',
     120            'sub',
     121            'summary',
     122            'sup',
     123            'table',
     124            'tbody',
     125            'td',
     126            'template',
     127            'textarea',
     128            'tfoot',
     129            'th',
     130            'thead',
     131            'time',
     132            'tr',
     133            'track',
     134            'tt',
     135            'u',
     136            'ul',
     137            'var',
     138            'video',
     139            'wbr',
    25140
    26141            // SVG
     
    93208            'feTurbulence',
    94209
     210            //MathML
     211            'math',
     212            'menclose',
     213            'merror',
     214            'mfenced',
     215            'mfrac',
     216            'mglyph',
     217            'mi',
     218            'mlabeledtr',
     219            'mmuliscripts',
     220            'mn',
     221            'mo',
     222            'mover',
     223            'mpadded',
     224            'mphantom',
     225            'mroot',
     226            'mrow',
     227            'ms',
     228            'mpspace',
     229            'msqrt',
     230            'mystyle',
     231            'msub',
     232            'msup',
     233            'msubsup',
     234            'mtable',
     235            'mtd',
     236            'mtext',
     237            'mtr',
     238            'munder',
     239            'munderover',
     240
    95241            //text
    96242            '#text'
  • svgplus/trunk/vendor/enshrined/svg-sanitize/src/data/AttributeInterface.php

    r3165214 r3165222  
    11<?php
    22namespace enshrined\svgSanitize\data;
     3
    34
    45/**
Note: See TracChangeset for help on using the changeset viewer.