first commit
This commit is contained in:
98
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/CssSelector.php
vendored
Normal file
98
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/CssSelector.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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 Symfony\Component\CssSelector;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\CssSelector class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the \Symfony\Component\CssSelector\CssSelectorConverter class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* CssSelector is the main entry point of the component and can convert CSS
|
||||
* selectors to XPath expressions.
|
||||
*
|
||||
* $xpath = CssSelector::toXpath('h1.foo');
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* Copyright (c) 2007-2012 Ian Bicking and contributors. See AUTHORS
|
||||
* for more details.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. Neither the name of Ian Bicking nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IAN BICKING OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated as of 2.8, will be removed in 3.0. Use the \Symfony\Component\CssSelector\CssSelectorConverter class instead.
|
||||
*/
|
||||
class CssSelector
|
||||
{
|
||||
private static $html = true;
|
||||
|
||||
/**
|
||||
* Translates a CSS expression to its XPath equivalent.
|
||||
* Optionally, a prefix can be added to the resulting XPath
|
||||
* expression with the $prefix parameter.
|
||||
*
|
||||
* @param mixed $cssExpr The CSS expression
|
||||
* @param string $prefix An optional prefix for the XPath expression
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toXPath($cssExpr, $prefix = 'descendant-or-self::')
|
||||
{
|
||||
$converter = new CssSelectorConverter(self::$html);
|
||||
|
||||
return $converter->toXPath($cssExpr, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the HTML extension.
|
||||
*/
|
||||
public static function enableHtmlExtension()
|
||||
{
|
||||
self::$html = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the HTML extension.
|
||||
*/
|
||||
public static function disableHtmlExtension()
|
||||
{
|
||||
self::$html = false;
|
||||
}
|
||||
}
|
||||
65
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/CssSelectorConverter.php
vendored
Normal file
65
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/CssSelectorConverter.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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 Symfony\Component\CssSelector;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser;
|
||||
use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser;
|
||||
use Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser;
|
||||
use Symfony\Component\CssSelector\Parser\Shortcut\HashParser;
|
||||
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
|
||||
use Symfony\Component\CssSelector\XPath\Translator;
|
||||
|
||||
/**
|
||||
* CssSelectorConverter is the main entry point of the component and can convert CSS
|
||||
* selectors to XPath expressions.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class CssSelectorConverter
|
||||
{
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* @param bool $html Whether HTML support should be enabled. Disable it for XML documents
|
||||
*/
|
||||
public function __construct($html = true)
|
||||
{
|
||||
$this->translator = new Translator();
|
||||
|
||||
if ($html) {
|
||||
$this->translator->registerExtension(new HtmlExtension($this->translator));
|
||||
}
|
||||
|
||||
$this->translator
|
||||
->registerParserShortcut(new EmptyStringParser())
|
||||
->registerParserShortcut(new ElementParser())
|
||||
->registerParserShortcut(new ClassParser())
|
||||
->registerParserShortcut(new HashParser())
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a CSS expression to its XPath equivalent.
|
||||
*
|
||||
* Optionally, a prefix can be added to the resulting XPath
|
||||
* expression with the $prefix parameter.
|
||||
*
|
||||
* @param string $cssExpr The CSS expression
|
||||
* @param string $prefix An optional prefix for the XPath expression
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toXPath($cssExpr, $prefix = 'descendant-or-self::')
|
||||
{
|
||||
return $this->translator->cssToXPath($cssExpr, $prefix);
|
||||
}
|
||||
}
|
||||
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/ExceptionInterface.php
vendored
Normal file
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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 Symfony\Component\CssSelector\Exception;
|
||||
|
||||
/**
|
||||
* Interface for exceptions.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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 Symfony\Component\CssSelector\Exception;
|
||||
|
||||
/**
|
||||
* ParseException is thrown when a CSS selector syntax is not valid.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class ExpressionErrorException extends ParseException
|
||||
{
|
||||
}
|
||||
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/InternalErrorException.php
vendored
Normal file
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/InternalErrorException.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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 Symfony\Component\CssSelector\Exception;
|
||||
|
||||
/**
|
||||
* ParseException is thrown when a CSS selector syntax is not valid.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class InternalErrorException extends ParseException
|
||||
{
|
||||
}
|
||||
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/ParseException.php
vendored
Normal file
24
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/ParseException.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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 Symfony\Component\CssSelector\Exception;
|
||||
|
||||
/**
|
||||
* ParseException is thrown when a CSS selector syntax is not valid.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ParseException extends \Exception implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
73
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/SyntaxErrorException.php
vendored
Normal file
73
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Exception/SyntaxErrorException.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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 Symfony\Component\CssSelector\Exception;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
|
||||
/**
|
||||
* ParseException is thrown when a CSS selector syntax is not valid.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class SyntaxErrorException extends ParseException
|
||||
{
|
||||
/**
|
||||
* @param string $expectedValue
|
||||
* @param Token $foundToken
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function unexpectedToken($expectedValue, Token $foundToken)
|
||||
{
|
||||
return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pseudoElement
|
||||
* @param string $unexpectedLocation
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function pseudoElementFound($pseudoElement, $unexpectedLocation)
|
||||
{
|
||||
return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $position
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function unclosedString($position)
|
||||
{
|
||||
return new self(sprintf('Unclosed/invalid string at %s.', $position));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public static function nestedNot()
|
||||
{
|
||||
return new self('Got nested ::not().');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public static function stringAsFunctionArgument()
|
||||
{
|
||||
return new self('String not allowed as function argument.');
|
||||
}
|
||||
}
|
||||
19
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/LICENSE
vendored
Normal file
19
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
42
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/AbstractNode.php
vendored
Normal file
42
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/AbstractNode.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Abstract base node class.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractNode implements NodeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $nodeName;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNodeName()
|
||||
{
|
||||
if (null === $this->nodeName) {
|
||||
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', \get_called_class());
|
||||
}
|
||||
|
||||
return $this->nodeName;
|
||||
}
|
||||
}
|
||||
107
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/AttributeNode.php
vendored
Normal file
107
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/AttributeNode.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>[<namespace>|<attribute> <operator> <value>]" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AttributeNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $namespace;
|
||||
private $attribute;
|
||||
private $operator;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $namespace
|
||||
* @param string $attribute
|
||||
* @param string $operator
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->namespace = $namespace;
|
||||
$this->attribute = $attribute;
|
||||
$this->operator = $operator;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAttribute()
|
||||
{
|
||||
return $this->attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator()
|
||||
{
|
||||
return $this->operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute;
|
||||
|
||||
return 'exists' === $this->operator
|
||||
? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute)
|
||||
: sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value);
|
||||
}
|
||||
}
|
||||
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/ClassNode.php
vendored
Normal file
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/ClassNode.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>.<name>" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ClassNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $name)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name);
|
||||
}
|
||||
}
|
||||
83
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/CombinedSelectorNode.php
vendored
Normal file
83
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/CombinedSelectorNode.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a combined node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CombinedSelectorNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $combinator;
|
||||
private $subSelector;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $combinator
|
||||
* @param NodeInterface $subSelector
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->combinator = $combinator;
|
||||
$this->subSelector = $subSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCombinator()
|
||||
{
|
||||
return $this->combinator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSubSelector()
|
||||
{
|
||||
return $this->subSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;
|
||||
|
||||
return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector);
|
||||
}
|
||||
}
|
||||
72
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/ElementNode.php
vendored
Normal file
72
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/ElementNode.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<namespace>|<element>" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ElementNode extends AbstractNode
|
||||
{
|
||||
private $namespace;
|
||||
private $element;
|
||||
|
||||
/**
|
||||
* @param string|null $namespace
|
||||
* @param string|null $element
|
||||
*/
|
||||
public function __construct($namespace = null, $element = null)
|
||||
{
|
||||
$this->namespace = $namespace;
|
||||
$this->element = $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getElement()
|
||||
{
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return new Specificity(0, 0, $this->element ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$element = $this->element ?: '*';
|
||||
|
||||
return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element);
|
||||
}
|
||||
}
|
||||
87
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/FunctionNode.php
vendored
Normal file
87
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/FunctionNode.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>:<name>(<arguments>)" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FunctionNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $name;
|
||||
private $arguments;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $name
|
||||
* @param Token[] $arguments
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $name, array $arguments = array())
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->name = strtolower($name);
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token[]
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$arguments = implode(', ', array_map(function (Token $token) {
|
||||
return "'".$token->getValue()."'";
|
||||
}, $this->arguments));
|
||||
|
||||
return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');
|
||||
}
|
||||
}
|
||||
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/HashNode.php
vendored
Normal file
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/HashNode.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>#<id>" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class HashNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $id
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $id)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id);
|
||||
}
|
||||
}
|
||||
66
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/NegationNode.php
vendored
Normal file
66
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/NegationNode.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>:not(<identifier>)" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class NegationNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $subSelector;
|
||||
|
||||
public function __construct(NodeInterface $selector, NodeInterface $subSelector)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->subSelector = $subSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSubSelector()
|
||||
{
|
||||
return $this->subSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector);
|
||||
}
|
||||
}
|
||||
46
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/NodeInterface.php
vendored
Normal file
46
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/NodeInterface.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Interface for nodes.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface NodeInterface
|
||||
{
|
||||
/**
|
||||
* Returns node's name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNodeName();
|
||||
|
||||
/**
|
||||
* Returns node's specificity.
|
||||
*
|
||||
* @return Specificity
|
||||
*/
|
||||
public function getSpecificity();
|
||||
|
||||
/**
|
||||
* Returns node's string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
}
|
||||
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/PseudoNode.php
vendored
Normal file
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/PseudoNode.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>:<identifier>" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PseudoNode extends AbstractNode
|
||||
{
|
||||
private $selector;
|
||||
private $identifier;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $selector
|
||||
* @param string $identifier
|
||||
*/
|
||||
public function __construct(NodeInterface $selector, $identifier)
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->identifier = strtolower($identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getSelector()
|
||||
{
|
||||
return $this->selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier);
|
||||
}
|
||||
}
|
||||
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/SelectorNode.php
vendored
Normal file
70
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/SelectorNode.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a "<selector>(::|:)<pseudoElement>" node.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class SelectorNode extends AbstractNode
|
||||
{
|
||||
private $tree;
|
||||
private $pseudoElement;
|
||||
|
||||
/**
|
||||
* @param NodeInterface $tree
|
||||
* @param string|null $pseudoElement
|
||||
*/
|
||||
public function __construct(NodeInterface $tree, $pseudoElement = null)
|
||||
{
|
||||
$this->tree = $tree;
|
||||
$this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getTree()
|
||||
{
|
||||
return $this->tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPseudoElement()
|
||||
{
|
||||
return $this->pseudoElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSpecificity()
|
||||
{
|
||||
return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : '');
|
||||
}
|
||||
}
|
||||
88
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/Specificity.php
vendored
Normal file
88
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Node/Specificity.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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 Symfony\Component\CssSelector\Node;
|
||||
|
||||
/**
|
||||
* Represents a node specificity.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @see http://www.w3.org/TR/selectors/#specificity
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Specificity
|
||||
{
|
||||
const A_FACTOR = 100;
|
||||
const B_FACTOR = 10;
|
||||
const C_FACTOR = 1;
|
||||
|
||||
private $a;
|
||||
private $b;
|
||||
private $c;
|
||||
|
||||
/**
|
||||
* @param int $a
|
||||
* @param int $b
|
||||
* @param int $c
|
||||
*/
|
||||
public function __construct($a, $b, $c)
|
||||
{
|
||||
$this->a = $a;
|
||||
$this->b = $b;
|
||||
$this->c = $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function plus(Specificity $specificity)
|
||||
{
|
||||
return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns global specificity value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 if the object specificity is lower than the argument,
|
||||
* 0 if they are equal, and 1 if the argument is lower.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compareTo(Specificity $specificity)
|
||||
{
|
||||
if ($this->a !== $specificity->a) {
|
||||
return $this->a > $specificity->a ? 1 : -1;
|
||||
}
|
||||
|
||||
if ($this->b !== $specificity->b) {
|
||||
return $this->b > $specificity->b ? 1 : -1;
|
||||
}
|
||||
|
||||
if ($this->c !== $specificity->c) {
|
||||
return $this->c > $specificity->c ? 1 : -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
48
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/CommentHandler.php
vendored
Normal file
48
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/CommentHandler.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector comment handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CommentHandler implements HandlerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
if ('/*' !== $reader->getSubstring(2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$offset = $reader->getOffset('*/');
|
||||
|
||||
if (false === $offset) {
|
||||
$reader->moveToEnd();
|
||||
} else {
|
||||
$reader->moveForward($offset + 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
33
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/HandlerInterface.php
vendored
Normal file
33
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/HandlerInterface.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector handler interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface HandlerInterface
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream);
|
||||
}
|
||||
58
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/HashHandler.php
vendored
Normal file
58
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/HashHandler.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector comment handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class HashHandler implements HandlerInterface
|
||||
{
|
||||
private $patterns;
|
||||
private $escaping;
|
||||
|
||||
public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
$this->escaping = $escaping;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
$match = $reader->findPattern($this->patterns->getHashPattern());
|
||||
|
||||
if (!$match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = $this->escaping->escapeUnicode($match[1]);
|
||||
$stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition()));
|
||||
$reader->moveForward(\strlen($match[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
58
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php
vendored
Normal file
58
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector comment handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class IdentifierHandler implements HandlerInterface
|
||||
{
|
||||
private $patterns;
|
||||
private $escaping;
|
||||
|
||||
public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
$this->escaping = $escaping;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
$match = $reader->findPattern($this->patterns->getIdentifierPattern());
|
||||
|
||||
if (!$match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = $this->escaping->escapeUnicode($match[0]);
|
||||
$stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition()));
|
||||
$reader->moveForward(\strlen($match[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
54
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/NumberHandler.php
vendored
Normal file
54
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/NumberHandler.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector comment handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class NumberHandler implements HandlerInterface
|
||||
{
|
||||
private $patterns;
|
||||
|
||||
public function __construct(TokenizerPatterns $patterns)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
$match = $reader->findPattern($this->patterns->getNumberPattern());
|
||||
|
||||
if (!$match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
|
||||
$reader->moveForward(\strlen($match[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
77
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/StringHandler.php
vendored
Normal file
77
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/StringHandler.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\InternalErrorException;
|
||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector comment handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class StringHandler implements HandlerInterface
|
||||
{
|
||||
private $patterns;
|
||||
private $escaping;
|
||||
|
||||
public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
$this->escaping = $escaping;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
$quote = $reader->getSubstring(1);
|
||||
|
||||
if (!\in_array($quote, array("'", '"'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$reader->moveForward(1);
|
||||
$match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote));
|
||||
|
||||
if (!$match) {
|
||||
throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition()));
|
||||
}
|
||||
|
||||
// check unclosed strings
|
||||
if (\strlen($match[0]) === $reader->getRemainingLength()) {
|
||||
throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
|
||||
}
|
||||
|
||||
// check quotes pairs validity
|
||||
if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) {
|
||||
throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
|
||||
}
|
||||
|
||||
$string = $this->escaping->escapeUnicodeAndNewLine($match[0]);
|
||||
$stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition()));
|
||||
$reader->moveForward(\strlen($match[0]) + 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
46
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/WhitespaceHandler.php
vendored
Normal file
46
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Handler/WhitespaceHandler.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Handler;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector whitespace handler.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WhitespaceHandler implements HandlerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Reader $reader, TokenStream $stream)
|
||||
{
|
||||
$match = $reader->findPattern('~^[ \t\r\n\f]+~');
|
||||
|
||||
if (false === $match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition()));
|
||||
$reader->moveForward(\strlen($match[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
384
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Parser.php
vendored
Normal file
384
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Parser.php
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||
use Symfony\Component\CssSelector\Node;
|
||||
use Symfony\Component\CssSelector\Parser\Tokenizer\Tokenizer;
|
||||
|
||||
/**
|
||||
* CSS selector parser.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Parser implements ParserInterface
|
||||
{
|
||||
private $tokenizer;
|
||||
|
||||
public function __construct(Tokenizer $tokenizer = null)
|
||||
{
|
||||
$this->tokenizer = $tokenizer ?: new Tokenizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($source)
|
||||
{
|
||||
$reader = new Reader($source);
|
||||
$stream = $this->tokenizer->tokenize($reader);
|
||||
|
||||
return $this->parseSelectorList($stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the arguments for ":nth-child()" and friends.
|
||||
*
|
||||
* @param Token[] $tokens
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws SyntaxErrorException
|
||||
*/
|
||||
public static function parseSeries(array $tokens)
|
||||
{
|
||||
foreach ($tokens as $token) {
|
||||
if ($token->isString()) {
|
||||
throw SyntaxErrorException::stringAsFunctionArgument();
|
||||
}
|
||||
}
|
||||
|
||||
$joined = trim(implode('', array_map(function (Token $token) {
|
||||
return $token->getValue();
|
||||
}, $tokens)));
|
||||
|
||||
$int = function ($string) {
|
||||
if (!is_numeric($string)) {
|
||||
throw SyntaxErrorException::stringAsFunctionArgument();
|
||||
}
|
||||
|
||||
return (int) $string;
|
||||
};
|
||||
|
||||
switch (true) {
|
||||
case 'odd' === $joined:
|
||||
return array(2, 1);
|
||||
case 'even' === $joined:
|
||||
return array(2, 0);
|
||||
case 'n' === $joined:
|
||||
return array(1, 0);
|
||||
case false === strpos($joined, 'n'):
|
||||
return array(0, $int($joined));
|
||||
}
|
||||
|
||||
$split = explode('n', $joined);
|
||||
$first = isset($split[0]) ? $split[0] : null;
|
||||
|
||||
return array(
|
||||
$first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1,
|
||||
isset($split[1]) && $split[1] ? $int($split[1]) : 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses selector nodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseSelectorList(TokenStream $stream)
|
||||
{
|
||||
$stream->skipWhitespace();
|
||||
$selectors = array();
|
||||
|
||||
while (true) {
|
||||
$selectors[] = $this->parserSelectorNode($stream);
|
||||
|
||||
if ($stream->getPeek()->isDelimiter(array(','))) {
|
||||
$stream->getNext();
|
||||
$stream->skipWhitespace();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses next selector or combined node.
|
||||
*
|
||||
* @return Node\SelectorNode
|
||||
*
|
||||
* @throws SyntaxErrorException
|
||||
*/
|
||||
private function parserSelectorNode(TokenStream $stream)
|
||||
{
|
||||
list($result, $pseudoElement) = $this->parseSimpleSelector($stream);
|
||||
|
||||
while (true) {
|
||||
$stream->skipWhitespace();
|
||||
$peek = $stream->getPeek();
|
||||
|
||||
if ($peek->isFileEnd() || $peek->isDelimiter(array(','))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (null !== $pseudoElement) {
|
||||
throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector');
|
||||
}
|
||||
|
||||
if ($peek->isDelimiter(array('+', '>', '~'))) {
|
||||
$combinator = $stream->getNext()->getValue();
|
||||
$stream->skipWhitespace();
|
||||
} else {
|
||||
$combinator = ' ';
|
||||
}
|
||||
|
||||
list($nextSelector, $pseudoElement) = $this->parseSimpleSelector($stream);
|
||||
$result = new Node\CombinedSelectorNode($result, $combinator, $nextSelector);
|
||||
}
|
||||
|
||||
return new Node\SelectorNode($result, $pseudoElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses next simple node (hash, class, pseudo, negation).
|
||||
*
|
||||
* @param TokenStream $stream
|
||||
* @param bool $insideNegation
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws SyntaxErrorException
|
||||
*/
|
||||
private function parseSimpleSelector(TokenStream $stream, $insideNegation = false)
|
||||
{
|
||||
$stream->skipWhitespace();
|
||||
|
||||
$selectorStart = \count($stream->getUsed());
|
||||
$result = $this->parseElementNode($stream);
|
||||
$pseudoElement = null;
|
||||
|
||||
while (true) {
|
||||
$peek = $stream->getPeek();
|
||||
if ($peek->isWhitespace()
|
||||
|| $peek->isFileEnd()
|
||||
|| $peek->isDelimiter(array(',', '+', '>', '~'))
|
||||
|| ($insideNegation && $peek->isDelimiter(array(')')))
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (null !== $pseudoElement) {
|
||||
throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector');
|
||||
}
|
||||
|
||||
if ($peek->isHash()) {
|
||||
$result = new Node\HashNode($result, $stream->getNext()->getValue());
|
||||
} elseif ($peek->isDelimiter(array('.'))) {
|
||||
$stream->getNext();
|
||||
$result = new Node\ClassNode($result, $stream->getNextIdentifier());
|
||||
} elseif ($peek->isDelimiter(array('['))) {
|
||||
$stream->getNext();
|
||||
$result = $this->parseAttributeNode($result, $stream);
|
||||
} elseif ($peek->isDelimiter(array(':'))) {
|
||||
$stream->getNext();
|
||||
|
||||
if ($stream->getPeek()->isDelimiter(array(':'))) {
|
||||
$stream->getNext();
|
||||
$pseudoElement = $stream->getNextIdentifier();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$identifier = $stream->getNextIdentifier();
|
||||
if (\in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
|
||||
// Special case: CSS 2.1 pseudo-elements can have a single ':'.
|
||||
// Any new pseudo-element must have two.
|
||||
$pseudoElement = $identifier;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$stream->getPeek()->isDelimiter(array('('))) {
|
||||
$result = new Node\PseudoNode($result, $identifier);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$stream->getNext();
|
||||
$stream->skipWhitespace();
|
||||
|
||||
if ('not' === strtolower($identifier)) {
|
||||
if ($insideNegation) {
|
||||
throw SyntaxErrorException::nestedNot();
|
||||
}
|
||||
|
||||
list($argument, $argumentPseudoElement) = $this->parseSimpleSelector($stream, true);
|
||||
$next = $stream->getNext();
|
||||
|
||||
if (null !== $argumentPseudoElement) {
|
||||
throw SyntaxErrorException::pseudoElementFound($argumentPseudoElement, 'inside ::not()');
|
||||
}
|
||||
|
||||
if (!$next->isDelimiter(array(')'))) {
|
||||
throw SyntaxErrorException::unexpectedToken('")"', $next);
|
||||
}
|
||||
|
||||
$result = new Node\NegationNode($result, $argument);
|
||||
} else {
|
||||
$arguments = array();
|
||||
$next = null;
|
||||
|
||||
while (true) {
|
||||
$stream->skipWhitespace();
|
||||
$next = $stream->getNext();
|
||||
|
||||
if ($next->isIdentifier()
|
||||
|| $next->isString()
|
||||
|| $next->isNumber()
|
||||
|| $next->isDelimiter(array('+', '-'))
|
||||
) {
|
||||
$arguments[] = $next;
|
||||
} elseif ($next->isDelimiter(array(')'))) {
|
||||
break;
|
||||
} else {
|
||||
throw SyntaxErrorException::unexpectedToken('an argument', $next);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($arguments)) {
|
||||
throw SyntaxErrorException::unexpectedToken('at least one argument', $next);
|
||||
}
|
||||
|
||||
$result = new Node\FunctionNode($result, $identifier, $arguments);
|
||||
}
|
||||
} else {
|
||||
throw SyntaxErrorException::unexpectedToken('selector', $peek);
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($stream->getUsed()) === $selectorStart) {
|
||||
throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek());
|
||||
}
|
||||
|
||||
return array($result, $pseudoElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses next element node.
|
||||
*
|
||||
* @return Node\ElementNode
|
||||
*/
|
||||
private function parseElementNode(TokenStream $stream)
|
||||
{
|
||||
$peek = $stream->getPeek();
|
||||
|
||||
if ($peek->isIdentifier() || $peek->isDelimiter(array('*'))) {
|
||||
if ($peek->isIdentifier()) {
|
||||
$namespace = $stream->getNext()->getValue();
|
||||
} else {
|
||||
$stream->getNext();
|
||||
$namespace = null;
|
||||
}
|
||||
|
||||
if ($stream->getPeek()->isDelimiter(array('|'))) {
|
||||
$stream->getNext();
|
||||
$element = $stream->getNextIdentifierOrStar();
|
||||
} else {
|
||||
$element = $namespace;
|
||||
$namespace = null;
|
||||
}
|
||||
} else {
|
||||
$element = $namespace = null;
|
||||
}
|
||||
|
||||
return new Node\ElementNode($namespace, $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses next attribute node.
|
||||
*
|
||||
* @return Node\AttributeNode
|
||||
*
|
||||
* @throws SyntaxErrorException
|
||||
*/
|
||||
private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $stream)
|
||||
{
|
||||
$stream->skipWhitespace();
|
||||
$attribute = $stream->getNextIdentifierOrStar();
|
||||
|
||||
if (null === $attribute && !$stream->getPeek()->isDelimiter(array('|'))) {
|
||||
throw SyntaxErrorException::unexpectedToken('"|"', $stream->getPeek());
|
||||
}
|
||||
|
||||
if ($stream->getPeek()->isDelimiter(array('|'))) {
|
||||
$stream->getNext();
|
||||
|
||||
if ($stream->getPeek()->isDelimiter(array('='))) {
|
||||
$namespace = null;
|
||||
$stream->getNext();
|
||||
$operator = '|=';
|
||||
} else {
|
||||
$namespace = $attribute;
|
||||
$attribute = $stream->getNextIdentifier();
|
||||
$operator = null;
|
||||
}
|
||||
} else {
|
||||
$namespace = $operator = null;
|
||||
}
|
||||
|
||||
if (null === $operator) {
|
||||
$stream->skipWhitespace();
|
||||
$next = $stream->getNext();
|
||||
|
||||
if ($next->isDelimiter(array(']'))) {
|
||||
return new Node\AttributeNode($selector, $namespace, $attribute, 'exists', null);
|
||||
} elseif ($next->isDelimiter(array('='))) {
|
||||
$operator = '=';
|
||||
} elseif ($next->isDelimiter(array('^', '$', '*', '~', '|', '!'))
|
||||
&& $stream->getPeek()->isDelimiter(array('='))
|
||||
) {
|
||||
$operator = $next->getValue().'=';
|
||||
$stream->getNext();
|
||||
} else {
|
||||
throw SyntaxErrorException::unexpectedToken('operator', $next);
|
||||
}
|
||||
}
|
||||
|
||||
$stream->skipWhitespace();
|
||||
$value = $stream->getNext();
|
||||
|
||||
if ($value->isNumber()) {
|
||||
// if the value is a number, it's casted into a string
|
||||
$value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition());
|
||||
}
|
||||
|
||||
if (!($value->isIdentifier() || $value->isString())) {
|
||||
throw SyntaxErrorException::unexpectedToken('string or identifier', $value);
|
||||
}
|
||||
|
||||
$stream->skipWhitespace();
|
||||
$next = $stream->getNext();
|
||||
|
||||
if (!$next->isDelimiter(array(']'))) {
|
||||
throw SyntaxErrorException::unexpectedToken('"]"', $next);
|
||||
}
|
||||
|
||||
return new Node\AttributeNode($selector, $namespace, $attribute, $operator, $value->getValue());
|
||||
}
|
||||
}
|
||||
36
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/ParserInterface.php
vendored
Normal file
36
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/ParserInterface.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
|
||||
/**
|
||||
* CSS selector parser interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface ParserInterface
|
||||
{
|
||||
/**
|
||||
* Parses given selector source into an array of tokens.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return SelectorNode[]
|
||||
*/
|
||||
public function parse($source);
|
||||
}
|
||||
114
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Reader.php
vendored
Normal file
114
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Reader.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser;
|
||||
|
||||
/**
|
||||
* CSS selector reader.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Reader
|
||||
{
|
||||
private $source;
|
||||
private $length;
|
||||
private $position = 0;
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct($source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->length = \strlen($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEOF()
|
||||
{
|
||||
return $this->position >= $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRemainingLength()
|
||||
{
|
||||
return $this->length - $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $length
|
||||
* @param int $offset
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubstring($length, $offset = 0)
|
||||
{
|
||||
return substr($this->source, $this->position + $offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffset($string)
|
||||
{
|
||||
$position = strpos($this->source, $string, $this->position);
|
||||
|
||||
return false === $position ? false : $position - $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function findPattern($pattern)
|
||||
{
|
||||
$source = substr($this->source, $this->position);
|
||||
|
||||
if (preg_match($pattern, $source, $matches)) {
|
||||
return $matches;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $length
|
||||
*/
|
||||
public function moveForward($length)
|
||||
{
|
||||
$this->position += $length;
|
||||
}
|
||||
|
||||
public function moveToEnd()
|
||||
{
|
||||
$this->position = $this->length;
|
||||
}
|
||||
}
|
||||
51
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/ClassParser.php
vendored
Normal file
51
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/ClassParser.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Shortcut;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\ClassNode;
|
||||
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
|
||||
/**
|
||||
* CSS selector class parser shortcut.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ClassParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($source)
|
||||
{
|
||||
// Matches an optional namespace, optional element, and required class
|
||||
// $source = 'test|input.ab6bd_field';
|
||||
// $matches = array (size=4)
|
||||
// 0 => string 'test|input.ab6bd_field' (length=22)
|
||||
// 1 => string 'test' (length=4)
|
||||
// 2 => string 'input' (length=5)
|
||||
// 3 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+\.([\w-]++)$/i', trim($source), $matches)) {
|
||||
return array(
|
||||
new SelectorNode(new ClassNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
|
||||
);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
47
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/ElementParser.php
vendored
Normal file
47
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/ElementParser.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Shortcut;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
|
||||
/**
|
||||
* CSS selector element parser shortcut.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ElementParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($source)
|
||||
{
|
||||
// Matches an optional namespace, required element or `*`
|
||||
// $source = 'testns|testel';
|
||||
// $matches = array (size=3)
|
||||
// 0 => string 'testns|testel' (length=13)
|
||||
// 1 => string 'testns' (length=6)
|
||||
// 2 => string 'testel' (length=6)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?([\w-]++|\*)$/i', trim($source), $matches)) {
|
||||
return array(new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2])));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Shortcut;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
|
||||
/**
|
||||
* CSS selector class parser shortcut.
|
||||
*
|
||||
* This shortcut ensure compatibility with previous version.
|
||||
* - The parser fails to parse an empty string.
|
||||
* - In the previous version, an empty string matches each tags.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class EmptyStringParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($source)
|
||||
{
|
||||
// Matches an empty string
|
||||
if ('' == $source) {
|
||||
return array(new SelectorNode(new ElementNode(null, '*')));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
51
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/HashParser.php
vendored
Normal file
51
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Shortcut/HashParser.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Shortcut;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||
use Symfony\Component\CssSelector\Node\HashNode;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
|
||||
/**
|
||||
* CSS selector hash parser shortcut.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class HashParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($source)
|
||||
{
|
||||
// Matches an optional namespace, optional element, and required id
|
||||
// $source = 'test|input#ab6bd_field';
|
||||
// $matches = array (size=4)
|
||||
// 0 => string 'test|input#ab6bd_field' (length=22)
|
||||
// 1 => string 'test' (length=4)
|
||||
// 2 => string 'input' (length=5)
|
||||
// 3 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+#([\w-]++)$/i', trim($source), $matches)) {
|
||||
return array(
|
||||
new SelectorNode(new HashNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
|
||||
);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
149
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Token.php
vendored
Normal file
149
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Token.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser;
|
||||
|
||||
/**
|
||||
* CSS selector token.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Token
|
||||
{
|
||||
const TYPE_FILE_END = 'eof';
|
||||
const TYPE_DELIMITER = 'delimiter';
|
||||
const TYPE_WHITESPACE = 'whitespace';
|
||||
const TYPE_IDENTIFIER = 'identifier';
|
||||
const TYPE_HASH = 'hash';
|
||||
const TYPE_NUMBER = 'number';
|
||||
const TYPE_STRING = 'string';
|
||||
|
||||
private $type;
|
||||
private $value;
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @param string $value
|
||||
* @param int $position
|
||||
*/
|
||||
public function __construct($type, $value, $position)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isFileEnd()
|
||||
{
|
||||
return self::TYPE_FILE_END === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelimiter(array $values = array())
|
||||
{
|
||||
if (self::TYPE_DELIMITER !== $this->type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($values)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \in_array($this->value, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWhitespace()
|
||||
{
|
||||
return self::TYPE_WHITESPACE === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isIdentifier()
|
||||
{
|
||||
return self::TYPE_IDENTIFIER === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHash()
|
||||
{
|
||||
return self::TYPE_HASH === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNumber()
|
||||
{
|
||||
return self::TYPE_NUMBER === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isString()
|
||||
{
|
||||
return self::TYPE_STRING === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->value) {
|
||||
return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position);
|
||||
}
|
||||
|
||||
return sprintf('<%s at %s>', $this->type, $this->position);
|
||||
}
|
||||
}
|
||||
175
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/TokenStream.php
vendored
Normal file
175
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/TokenStream.php
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\InternalErrorException;
|
||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||
|
||||
/**
|
||||
* CSS selector token stream.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TokenStream
|
||||
{
|
||||
/**
|
||||
* @var Token[]
|
||||
*/
|
||||
private $tokens = array();
|
||||
|
||||
/**
|
||||
* @var Token[]
|
||||
*/
|
||||
private $used = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $cursor = 0;
|
||||
|
||||
/**
|
||||
* @var Token|null
|
||||
*/
|
||||
private $peeked;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $peeking = false;
|
||||
|
||||
/**
|
||||
* Pushes a token.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function push(Token $token)
|
||||
{
|
||||
$this->tokens[] = $token;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Freezes stream.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function freeze()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next token.
|
||||
*
|
||||
* @return Token
|
||||
*
|
||||
* @throws InternalErrorException If there is no more token
|
||||
*/
|
||||
public function getNext()
|
||||
{
|
||||
if ($this->peeking) {
|
||||
$this->peeking = false;
|
||||
$this->used[] = $this->peeked;
|
||||
|
||||
return $this->peeked;
|
||||
}
|
||||
|
||||
if (!isset($this->tokens[$this->cursor])) {
|
||||
throw new InternalErrorException('Unexpected token stream end.');
|
||||
}
|
||||
|
||||
return $this->tokens[$this->cursor++];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns peeked token.
|
||||
*
|
||||
* @return Token
|
||||
*/
|
||||
public function getPeek()
|
||||
{
|
||||
if (!$this->peeking) {
|
||||
$this->peeked = $this->getNext();
|
||||
$this->peeking = true;
|
||||
}
|
||||
|
||||
return $this->peeked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns used tokens.
|
||||
*
|
||||
* @return Token[]
|
||||
*/
|
||||
public function getUsed()
|
||||
{
|
||||
return $this->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns nex identifier token.
|
||||
*
|
||||
* @return string The identifier token value
|
||||
*
|
||||
* @throws SyntaxErrorException If next token is not an identifier
|
||||
*/
|
||||
public function getNextIdentifier()
|
||||
{
|
||||
$next = $this->getNext();
|
||||
|
||||
if (!$next->isIdentifier()) {
|
||||
throw SyntaxErrorException::unexpectedToken('identifier', $next);
|
||||
}
|
||||
|
||||
return $next->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns nex identifier or star delimiter token.
|
||||
*
|
||||
* @return string|null The identifier token value or null if star found
|
||||
*
|
||||
* @throws SyntaxErrorException If next token is not an identifier or a star delimiter
|
||||
*/
|
||||
public function getNextIdentifierOrStar()
|
||||
{
|
||||
$next = $this->getNext();
|
||||
|
||||
if ($next->isIdentifier()) {
|
||||
return $next->getValue();
|
||||
}
|
||||
|
||||
if ($next->isDelimiter(array('*'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips next whitespace if any.
|
||||
*/
|
||||
public function skipWhitespace()
|
||||
{
|
||||
$peek = $this->getPeek();
|
||||
|
||||
if ($peek->isWhitespace()) {
|
||||
$this->getNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
75
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Tokenizer/Tokenizer.php
vendored
Normal file
75
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Tokenizer/Tokenizer.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Tokenizer;
|
||||
|
||||
use Symfony\Component\CssSelector\Parser\Handler;
|
||||
use Symfony\Component\CssSelector\Parser\Reader;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
/**
|
||||
* CSS selector tokenizer.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Tokenizer
|
||||
{
|
||||
/**
|
||||
* @var Handler\HandlerInterface[]
|
||||
*/
|
||||
private $handlers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$patterns = new TokenizerPatterns();
|
||||
$escaping = new TokenizerEscaping($patterns);
|
||||
|
||||
$this->handlers = array(
|
||||
new Handler\WhitespaceHandler(),
|
||||
new Handler\IdentifierHandler($patterns, $escaping),
|
||||
new Handler\HashHandler($patterns, $escaping),
|
||||
new Handler\StringHandler($patterns, $escaping),
|
||||
new Handler\NumberHandler($patterns),
|
||||
new Handler\CommentHandler(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize selector source code.
|
||||
*
|
||||
* @return TokenStream
|
||||
*/
|
||||
public function tokenize(Reader $reader)
|
||||
{
|
||||
$stream = new TokenStream();
|
||||
|
||||
while (!$reader->isEOF()) {
|
||||
foreach ($this->handlers as $handler) {
|
||||
if ($handler->handle($reader, $stream)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$stream->push(new Token(Token::TYPE_DELIMITER, $reader->getSubstring(1), $reader->getPosition()));
|
||||
$reader->moveForward(1);
|
||||
}
|
||||
|
||||
return $stream
|
||||
->push(new Token(Token::TYPE_FILE_END, null, $reader->getPosition()))
|
||||
->freeze();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Tokenizer;
|
||||
|
||||
/**
|
||||
* CSS selector tokenizer escaping applier.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TokenizerEscaping
|
||||
{
|
||||
private $patterns;
|
||||
|
||||
public function __construct(TokenizerPatterns $patterns)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeUnicode($value)
|
||||
{
|
||||
$value = $this->replaceUnicodeSequences($value);
|
||||
|
||||
return preg_replace($this->patterns->getSimpleEscapePattern(), '$1', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeUnicodeAndNewLine($value)
|
||||
{
|
||||
$value = preg_replace($this->patterns->getNewLineEscapePattern(), '', $value);
|
||||
|
||||
return $this->escapeUnicode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function replaceUnicodeSequences($value)
|
||||
{
|
||||
return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) {
|
||||
$c = hexdec($match[1]);
|
||||
|
||||
if (0x80 > $c %= 0x200000) {
|
||||
return \chr($c);
|
||||
}
|
||||
if (0x800 > $c) {
|
||||
return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
if (0x10000 > $c) {
|
||||
return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
}, $value);
|
||||
}
|
||||
}
|
||||
112
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php
vendored
Normal file
112
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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 Symfony\Component\CssSelector\Parser\Tokenizer;
|
||||
|
||||
/**
|
||||
* CSS selector tokenizer patterns builder.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TokenizerPatterns
|
||||
{
|
||||
private $unicodeEscapePattern;
|
||||
private $simpleEscapePattern;
|
||||
private $newLineEscapePattern;
|
||||
private $escapePattern;
|
||||
private $stringEscapePattern;
|
||||
private $nonAsciiPattern;
|
||||
private $nmCharPattern;
|
||||
private $nmStartPattern;
|
||||
private $identifierPattern;
|
||||
private $hashPattern;
|
||||
private $numberPattern;
|
||||
private $quotedStringPattern;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->unicodeEscapePattern = '\\\\([0-9a-f]{1,6})(?:\r\n|[ \n\r\t\f])?';
|
||||
$this->simpleEscapePattern = '\\\\(.)';
|
||||
$this->newLineEscapePattern = '\\\\(?:\n|\r\n|\r|\f)';
|
||||
$this->escapePattern = $this->unicodeEscapePattern.'|\\\\[^\n\r\f0-9a-f]';
|
||||
$this->stringEscapePattern = $this->newLineEscapePattern.'|'.$this->escapePattern;
|
||||
$this->nonAsciiPattern = '[^\x00-\x7F]';
|
||||
$this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
|
||||
$this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
|
||||
$this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*';
|
||||
$this->hashPattern = '#((?:'.$this->nmCharPattern.')+)';
|
||||
$this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)';
|
||||
$this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNewLineEscapePattern()
|
||||
{
|
||||
return '~^'.$this->newLineEscapePattern.'~';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSimpleEscapePattern()
|
||||
{
|
||||
return '~^'.$this->simpleEscapePattern.'~';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUnicodeEscapePattern()
|
||||
{
|
||||
return '~^'.$this->unicodeEscapePattern.'~i';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIdentifierPattern()
|
||||
{
|
||||
return '~^'.$this->identifierPattern.'~i';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHashPattern()
|
||||
{
|
||||
return '~^'.$this->hashPattern.'~i';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNumberPattern()
|
||||
{
|
||||
return '~^'.$this->numberPattern.'~';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $quote
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuotedStringPattern($quote)
|
||||
{
|
||||
return '~^'.sprintf($this->quotedStringPattern, $quote).'~i';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
/**
|
||||
* XPath expression translator abstract extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractExtension implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodeTranslators()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCombinationTranslators()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributeMatchingTranslators()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\XPath\Translator;
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator attribute extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AttributeMatchingExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributeMatchingTranslators()
|
||||
{
|
||||
return array(
|
||||
'exists' => array($this, 'translateExists'),
|
||||
'=' => array($this, 'translateEquals'),
|
||||
'~=' => array($this, 'translateIncludes'),
|
||||
'|=' => array($this, 'translateDashMatch'),
|
||||
'^=' => array($this, 'translatePrefixMatch'),
|
||||
'$=' => array($this, 'translateSuffixMatch'),
|
||||
'*=' => array($this, 'translateSubstringMatch'),
|
||||
'!=' => array($this, 'translateDifferent'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateExists(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition($attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateEquals(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateIncludes(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral(' '.$value.' ')
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDashMatch(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
'%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value),
|
||||
Translator::getXpathLiteral($value.'-')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and starts-with(%1$s, %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
|
||||
$attribute,
|
||||
\strlen($value) - 1,
|
||||
Translator::getXpathLiteral($value)
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and contains(%1$s, %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDifferent(XPathExpr $xpath, $attribute, $value)
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
$value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'attribute-matching';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator combination extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CombinationExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCombinationTranslators()
|
||||
{
|
||||
return array(
|
||||
' ' => array($this, 'translateDescendant'),
|
||||
'>' => array($this, 'translateChild'),
|
||||
'+' => array($this, 'translateDirectAdjacent'),
|
||||
'~' => array($this, 'translateIndirectAdjacent'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath)
|
||||
{
|
||||
return $xpath->join('/descendant-or-self::*/', $combinedXpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath)
|
||||
{
|
||||
return $xpath->join('/', $combinedXpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath)
|
||||
{
|
||||
return $xpath
|
||||
->join('/following-sibling::', $combinedXpath)
|
||||
->addNameTest()
|
||||
->addCondition('position() = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath)
|
||||
{
|
||||
return $xpath->join('/following-sibling::', $combinedXpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'combination';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
/**
|
||||
* XPath expression translator extension interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* Returns node translators.
|
||||
*
|
||||
* These callables will receive the node as first argument and the translator as second argument.
|
||||
*
|
||||
* @return callable[]
|
||||
*/
|
||||
public function getNodeTranslators();
|
||||
|
||||
/**
|
||||
* Returns combination translators.
|
||||
*
|
||||
* @return callable[]
|
||||
*/
|
||||
public function getCombinationTranslators();
|
||||
|
||||
/**
|
||||
* Returns function translators.
|
||||
*
|
||||
* @return callable[]
|
||||
*/
|
||||
public function getFunctionTranslators();
|
||||
|
||||
/**
|
||||
* Returns pseudo-class translators.
|
||||
*
|
||||
* @return callable[]
|
||||
*/
|
||||
public function getPseudoClassTranslators();
|
||||
|
||||
/**
|
||||
* Returns attribute operation translators.
|
||||
*
|
||||
* @return callable[]
|
||||
*/
|
||||
public function getAttributeMatchingTranslators();
|
||||
|
||||
/**
|
||||
* Returns extension name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
}
|
||||
190
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
vendored
Normal file
190
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||
use Symfony\Component\CssSelector\Parser\Parser;
|
||||
use Symfony\Component\CssSelector\XPath\Translator;
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator function extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FunctionExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators()
|
||||
{
|
||||
return array(
|
||||
'nth-child' => array($this, 'translateNthChild'),
|
||||
'nth-last-child' => array($this, 'translateNthLastChild'),
|
||||
'nth-of-type' => array($this, 'translateNthOfType'),
|
||||
'nth-last-of-type' => array($this, 'translateNthLastOfType'),
|
||||
'contains' => array($this, 'translateContains'),
|
||||
'lang' => array($this, 'translateLang'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param FunctionNode $function
|
||||
* @param bool $last
|
||||
* @param bool $addNameTest
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true)
|
||||
{
|
||||
try {
|
||||
list($a, $b) = Parser::parseSeries($function->getArguments());
|
||||
} catch (SyntaxErrorException $e) {
|
||||
throw new ExpressionErrorException(sprintf('Invalid series: %s', implode(', ', $function->getArguments())), 0, $e);
|
||||
}
|
||||
|
||||
$xpath->addStarPrefix();
|
||||
if ($addNameTest) {
|
||||
$xpath->addNameTest();
|
||||
}
|
||||
|
||||
if (0 === $a) {
|
||||
return $xpath->addCondition('position() = '.($last ? 'last() - '.($b - 1) : $b));
|
||||
}
|
||||
|
||||
if ($a < 0) {
|
||||
if ($b < 1) {
|
||||
return $xpath->addCondition('false()');
|
||||
}
|
||||
|
||||
$sign = '<=';
|
||||
} else {
|
||||
$sign = '>=';
|
||||
}
|
||||
|
||||
$expr = 'position()';
|
||||
|
||||
if ($last) {
|
||||
$expr = 'last() - '.$expr;
|
||||
--$b;
|
||||
}
|
||||
|
||||
if (0 !== $b) {
|
||||
$expr .= ' - '.$b;
|
||||
}
|
||||
|
||||
$conditions = array(sprintf('%s %s 0', $expr, $sign));
|
||||
|
||||
if (1 !== $a && -1 !== $a) {
|
||||
$conditions[] = sprintf('(%s) mod %d = 0', $expr, $a);
|
||||
}
|
||||
|
||||
return $xpath->addCondition(implode(' and ', $conditions));
|
||||
|
||||
// todo: handle an+b, odd, even
|
||||
// an+b means every-a, plus b, e.g., 2n+1 means odd
|
||||
// 0n+b means b
|
||||
// n+0 means a=1, i.e., all elements
|
||||
// an means every a elements, i.e., 2n means even
|
||||
// -n means -1n
|
||||
// -1n+6 means elements 6 and previous
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
return $this->translateNthChild($xpath, $function, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNthOfType(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
return $this->translateNthChild($xpath, $function, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
if ('*' === $xpath->getElement()) {
|
||||
throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.');
|
||||
}
|
||||
|
||||
return $this->translateNthChild($xpath, $function, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateContains(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
if (!($token->isString() || $token->isIdentifier())) {
|
||||
throw new ExpressionErrorException('Expected a single string or identifier for :contains(), got '.implode(', ', $arguments));
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
'contains(string(.), %s)',
|
||||
Translator::getXpathLiteral($arguments[0]->getValue())
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
if (!($token->isString() || $token->isIdentifier())) {
|
||||
throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
'lang(%s)',
|
||||
Translator::getXpathLiteral($arguments[0]->getValue())
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'function';
|
||||
}
|
||||
}
|
||||
213
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
vendored
Normal file
213
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
||||
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||
use Symfony\Component\CssSelector\XPath\Translator;
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator HTML extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class HtmlExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(Translator $translator)
|
||||
{
|
||||
$translator
|
||||
->getExtension('node')
|
||||
->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true)
|
||||
->setFlag(NodeExtension::ATTRIBUTE_NAME_IN_LOWER_CASE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators()
|
||||
{
|
||||
return array(
|
||||
'checked' => array($this, 'translateChecked'),
|
||||
'link' => array($this, 'translateLink'),
|
||||
'disabled' => array($this, 'translateDisabled'),
|
||||
'enabled' => array($this, 'translateEnabled'),
|
||||
'selected' => array($this, 'translateSelected'),
|
||||
'invalid' => array($this, 'translateInvalid'),
|
||||
'hover' => array($this, 'translateHover'),
|
||||
'visited' => array($this, 'translateVisited'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators()
|
||||
{
|
||||
return array(
|
||||
'lang' => array($this, 'translateLang'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateChecked(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'(@checked '
|
||||
."and (name(.) = 'input' or name(.) = 'command')"
|
||||
."and (@type = 'checkbox' or @type = 'radio'))"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateLink(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDisabled(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'('
|
||||
.'@disabled and'
|
||||
.'('
|
||||
."(name(.) = 'input' and @type != 'hidden')"
|
||||
." or name(.) = 'button'"
|
||||
." or name(.) = 'select'"
|
||||
." or name(.) = 'textarea'"
|
||||
." or name(.) = 'command'"
|
||||
." or name(.) = 'fieldset'"
|
||||
." or name(.) = 'optgroup'"
|
||||
." or name(.) = 'option'"
|
||||
.')'
|
||||
.') or ('
|
||||
."(name(.) = 'input' and @type != 'hidden')"
|
||||
." or name(.) = 'button'"
|
||||
." or name(.) = 'select'"
|
||||
." or name(.) = 'textarea'"
|
||||
.')'
|
||||
.' and ancestor::fieldset[@disabled]'
|
||||
);
|
||||
// todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateEnabled(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'('
|
||||
.'@href and ('
|
||||
."name(.) = 'a'"
|
||||
." or name(.) = 'link'"
|
||||
." or name(.) = 'area'"
|
||||
.')'
|
||||
.') or ('
|
||||
.'('
|
||||
."name(.) = 'command'"
|
||||
." or name(.) = 'fieldset'"
|
||||
." or name(.) = 'optgroup'"
|
||||
.')'
|
||||
.' and not(@disabled)'
|
||||
.') or ('
|
||||
.'('
|
||||
."(name(.) = 'input' and @type != 'hidden')"
|
||||
." or name(.) = 'button'"
|
||||
." or name(.) = 'select'"
|
||||
." or name(.) = 'textarea'"
|
||||
." or name(.) = 'keygen'"
|
||||
.')'
|
||||
.' and not (@disabled or ancestor::fieldset[@disabled])'
|
||||
.') or ('
|
||||
."name(.) = 'option' and not("
|
||||
.'@disabled or ancestor::optgroup[@disabled]'
|
||||
.')'
|
||||
.')'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
if (!($token->isString() || $token->isIdentifier())) {
|
||||
throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
'ancestor-or-self::*[@lang][1][starts-with(concat('
|
||||
."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
|
||||
.', %s)]',
|
||||
'lang',
|
||||
Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSelected(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition("(@selected and name(.) = 'option')");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateInvalid(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateHover(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateVisited(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'html';
|
||||
}
|
||||
}
|
||||
242
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
vendored
Normal file
242
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\Node;
|
||||
use Symfony\Component\CssSelector\XPath\Translator;
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator node extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class NodeExtension extends AbstractExtension
|
||||
{
|
||||
const ELEMENT_NAME_IN_LOWER_CASE = 1;
|
||||
const ATTRIBUTE_NAME_IN_LOWER_CASE = 2;
|
||||
const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4;
|
||||
|
||||
private $flags;
|
||||
|
||||
/**
|
||||
* @param int $flags
|
||||
*/
|
||||
public function __construct($flags = 0)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $flag
|
||||
* @param bool $on
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFlag($flag, $on)
|
||||
{
|
||||
if ($on && !$this->hasFlag($flag)) {
|
||||
$this->flags += $flag;
|
||||
}
|
||||
|
||||
if (!$on && $this->hasFlag($flag)) {
|
||||
$this->flags -= $flag;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $flag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFlag($flag)
|
||||
{
|
||||
return (bool) ($this->flags & $flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodeTranslators()
|
||||
{
|
||||
return array(
|
||||
'Selector' => array($this, 'translateSelector'),
|
||||
'CombinedSelector' => array($this, 'translateCombinedSelector'),
|
||||
'Negation' => array($this, 'translateNegation'),
|
||||
'Function' => array($this, 'translateFunction'),
|
||||
'Pseudo' => array($this, 'translatePseudo'),
|
||||
'Attribute' => array($this, 'translateAttribute'),
|
||||
'Class' => array($this, 'translateClass'),
|
||||
'Hash' => array($this, 'translateHash'),
|
||||
'Element' => array($this, 'translateElement'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSelector(Node\SelectorNode $node, Translator $translator)
|
||||
{
|
||||
return $translator->nodeToXPath($node->getTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator)
|
||||
{
|
||||
return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNegation(Node\NegationNode $node, Translator $translator)
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
$subXpath = $translator->nodeToXPath($node->getSubSelector());
|
||||
$subXpath->addNameTest();
|
||||
|
||||
if ($subXpath->getCondition()) {
|
||||
return $xpath->addCondition(sprintf('not(%s)', $subXpath->getCondition()));
|
||||
}
|
||||
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateFunction(Node\FunctionNode $node, Translator $translator)
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addFunction($xpath, $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translatePseudo(Node\PseudoNode $node, Translator $translator)
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addPseudoClass($xpath, $node->getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateAttribute(Node\AttributeNode $node, Translator $translator)
|
||||
{
|
||||
$name = $node->getAttribute();
|
||||
$safe = $this->isSafeName($name);
|
||||
|
||||
if ($this->hasFlag(self::ATTRIBUTE_NAME_IN_LOWER_CASE)) {
|
||||
$name = strtolower($name);
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$name = sprintf('%s:%s', $node->getNamespace(), $name);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
$attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
|
||||
$value = $node->getValue();
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) {
|
||||
$value = strtolower($value);
|
||||
}
|
||||
|
||||
return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateClass(Node\ClassNode $node, Translator $translator)
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateHash(Node\HashNode $node, Translator $translator)
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateElement(Node\ElementNode $node)
|
||||
{
|
||||
$element = $node->getElement();
|
||||
|
||||
if ($this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) {
|
||||
$element = strtolower($element);
|
||||
}
|
||||
|
||||
if ($element) {
|
||||
$safe = $this->isSafeName($element);
|
||||
} else {
|
||||
$element = '*';
|
||||
$safe = true;
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$element = sprintf('%s:%s', $node->getNamespace(), $element);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
$xpath = new XPathExpr('', $element);
|
||||
|
||||
if (!$safe) {
|
||||
$xpath->addNameTest();
|
||||
}
|
||||
|
||||
return $xpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'node';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if given name is safe.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isSafeName($name)
|
||||
{
|
||||
return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name);
|
||||
}
|
||||
}
|
||||
148
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php
vendored
Normal file
148
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath\Extension;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
||||
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
|
||||
/**
|
||||
* XPath expression translator pseudo-class extension.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PseudoClassExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators()
|
||||
{
|
||||
return array(
|
||||
'root' => array($this, 'translateRoot'),
|
||||
'first-child' => array($this, 'translateFirstChild'),
|
||||
'last-child' => array($this, 'translateLastChild'),
|
||||
'first-of-type' => array($this, 'translateFirstOfType'),
|
||||
'last-of-type' => array($this, 'translateLastOfType'),
|
||||
'only-child' => array($this, 'translateOnlyChild'),
|
||||
'only-of-type' => array($this, 'translateOnlyOfType'),
|
||||
'empty' => array($this, 'translateEmpty'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateRoot(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition('not(parent::*)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateFirstChild(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath
|
||||
->addStarPrefix()
|
||||
->addNameTest()
|
||||
->addCondition('position() = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateLastChild(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath
|
||||
->addStarPrefix()
|
||||
->addNameTest()
|
||||
->addCondition('position() = last()');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateFirstOfType(XPathExpr $xpath)
|
||||
{
|
||||
if ('*' === $xpath->getElement()) {
|
||||
throw new ExpressionErrorException('"*:first-of-type" is not implemented.');
|
||||
}
|
||||
|
||||
return $xpath
|
||||
->addStarPrefix()
|
||||
->addCondition('position() = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateLastOfType(XPathExpr $xpath)
|
||||
{
|
||||
if ('*' === $xpath->getElement()) {
|
||||
throw new ExpressionErrorException('"*:last-of-type" is not implemented.');
|
||||
}
|
||||
|
||||
return $xpath
|
||||
->addStarPrefix()
|
||||
->addCondition('position() = last()');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateOnlyChild(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath
|
||||
->addStarPrefix()
|
||||
->addNameTest()
|
||||
->addCondition('last() = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateOnlyOfType(XPathExpr $xpath)
|
||||
{
|
||||
if ('*' === $xpath->getElement()) {
|
||||
throw new ExpressionErrorException('"*:only-of-type" is not implemented.');
|
||||
}
|
||||
|
||||
return $xpath->addCondition('last() = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateEmpty(XPathExpr $xpath)
|
||||
{
|
||||
return $xpath->addCondition('not(*) and not(string-length())');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'pseudo-class';
|
||||
}
|
||||
}
|
||||
267
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Translator.php
vendored
Normal file
267
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/Translator.php
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath;
|
||||
|
||||
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
||||
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||
use Symfony\Component\CssSelector\Node\NodeInterface;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
use Symfony\Component\CssSelector\Parser\Parser;
|
||||
use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
|
||||
/**
|
||||
* XPath expression translator interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Translator implements TranslatorInterface
|
||||
{
|
||||
private $mainParser;
|
||||
|
||||
/**
|
||||
* @var ParserInterface[]
|
||||
*/
|
||||
private $shortcutParsers = array();
|
||||
|
||||
/**
|
||||
* @var Extension\ExtensionInterface[]
|
||||
*/
|
||||
private $extensions = array();
|
||||
|
||||
private $nodeTranslators = array();
|
||||
private $combinationTranslators = array();
|
||||
private $functionTranslators = array();
|
||||
private $pseudoClassTranslators = array();
|
||||
private $attributeMatchingTranslators = array();
|
||||
|
||||
public function __construct(ParserInterface $parser = null)
|
||||
{
|
||||
$this->mainParser = $parser ?: new Parser();
|
||||
|
||||
$this
|
||||
->registerExtension(new Extension\NodeExtension())
|
||||
->registerExtension(new Extension\CombinationExtension())
|
||||
->registerExtension(new Extension\FunctionExtension())
|
||||
->registerExtension(new Extension\PseudoClassExtension())
|
||||
->registerExtension(new Extension\AttributeMatchingExtension())
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getXpathLiteral($element)
|
||||
{
|
||||
if (false === strpos($element, "'")) {
|
||||
return "'".$element."'";
|
||||
}
|
||||
|
||||
if (false === strpos($element, '"')) {
|
||||
return '"'.$element.'"';
|
||||
}
|
||||
|
||||
$string = $element;
|
||||
$parts = array();
|
||||
while (true) {
|
||||
if (false !== $pos = strpos($string, "'")) {
|
||||
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
|
||||
$parts[] = "\"'\"";
|
||||
$string = substr($string, $pos + 1);
|
||||
} else {
|
||||
$parts[] = "'$string'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf('concat(%s)', implode(', ', $parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::')
|
||||
{
|
||||
$selectors = $this->parseSelectors($cssExpr);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
foreach ($selectors as $index => $selector) {
|
||||
if (null !== $selector->getPseudoElement()) {
|
||||
throw new ExpressionErrorException('Pseudo-elements are not supported.');
|
||||
}
|
||||
|
||||
$selectors[$index] = $this->selectorToXPath($selector, $prefix);
|
||||
}
|
||||
|
||||
return implode(' | ', $selectors);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::')
|
||||
{
|
||||
return ($prefix ?: '').$this->nodeToXPath($selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an extension.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function registerExtension(Extension\ExtensionInterface $extension)
|
||||
{
|
||||
$this->extensions[$extension->getName()] = $extension;
|
||||
|
||||
$this->nodeTranslators = array_merge($this->nodeTranslators, $extension->getNodeTranslators());
|
||||
$this->combinationTranslators = array_merge($this->combinationTranslators, $extension->getCombinationTranslators());
|
||||
$this->functionTranslators = array_merge($this->functionTranslators, $extension->getFunctionTranslators());
|
||||
$this->pseudoClassTranslators = array_merge($this->pseudoClassTranslators, $extension->getPseudoClassTranslators());
|
||||
$this->attributeMatchingTranslators = array_merge($this->attributeMatchingTranslators, $extension->getAttributeMatchingTranslators());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Extension\ExtensionInterface
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function getExtension($name)
|
||||
{
|
||||
if (!isset($this->extensions[$name])) {
|
||||
throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name));
|
||||
}
|
||||
|
||||
return $this->extensions[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a shortcut parser.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function registerParserShortcut(ParserInterface $shortcut)
|
||||
{
|
||||
$this->shortcutParsers[] = $shortcut;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function nodeToXPath(NodeInterface $node)
|
||||
{
|
||||
if (!isset($this->nodeTranslators[$node->getNodeName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
|
||||
}
|
||||
|
||||
return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $combiner
|
||||
* @param NodeInterface $xpath
|
||||
* @param NodeInterface $combinedXpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addCombination($combiner, NodeInterface $xpath, NodeInterface $combinedXpath)
|
||||
{
|
||||
if (!isset($this->combinationTranslators[$combiner])) {
|
||||
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
|
||||
}
|
||||
|
||||
return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addFunction(XPathExpr $xpath, FunctionNode $function)
|
||||
{
|
||||
if (!isset($this->functionTranslators[$function->getName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
|
||||
}
|
||||
|
||||
return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $pseudoClass
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addPseudoClass(XPathExpr $xpath, $pseudoClass)
|
||||
{
|
||||
if (!isset($this->pseudoClassTranslators[$pseudoClass])) {
|
||||
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
|
||||
}
|
||||
|
||||
return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $operator
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $value)
|
||||
{
|
||||
if (!isset($this->attributeMatchingTranslators[$operator])) {
|
||||
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
|
||||
}
|
||||
|
||||
return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
*
|
||||
* @return SelectorNode[]
|
||||
*/
|
||||
private function parseSelectors($css)
|
||||
{
|
||||
foreach ($this->shortcutParsers as $shortcut) {
|
||||
$tokens = $shortcut->parse($css);
|
||||
|
||||
if (!empty($tokens)) {
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->mainParser->parse($css);
|
||||
}
|
||||
}
|
||||
47
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/TranslatorInterface.php
vendored
Normal file
47
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/TranslatorInterface.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath;
|
||||
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
|
||||
/**
|
||||
* XPath expression translator interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface TranslatorInterface
|
||||
{
|
||||
/**
|
||||
* Translates a CSS selector to an XPath expression.
|
||||
*
|
||||
* @param string $cssExpr
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
|
||||
|
||||
/**
|
||||
* Translates a parsed selector node to an XPath expression.
|
||||
*
|
||||
* @param SelectorNode $selector
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::');
|
||||
}
|
||||
131
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
Normal file
131
wp-content/plugins/wpforms-lite/vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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 Symfony\Component\CssSelector\XPath;
|
||||
|
||||
/**
|
||||
* XPath expression translator interface.
|
||||
*
|
||||
* This component is a port of the Python cssselect library,
|
||||
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class XPathExpr
|
||||
{
|
||||
private $path;
|
||||
private $element;
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $element
|
||||
* @param string $condition
|
||||
* @param bool $starPrefix
|
||||
*/
|
||||
public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->element = $element;
|
||||
$this->condition = $condition;
|
||||
|
||||
if ($starPrefix) {
|
||||
$this->addStarPrefix();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getElement()
|
||||
{
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $condition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addCondition($condition)
|
||||
{
|
||||
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addNameTest()
|
||||
{
|
||||
if ('*' !== $this->element) {
|
||||
$this->addCondition('name() = '.Translator::getXpathLiteral($this->element));
|
||||
$this->element = '*';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addStarPrefix()
|
||||
{
|
||||
$this->path .= '*/';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins another XPathExpr with a combiner.
|
||||
*
|
||||
* @param string $combiner
|
||||
* @param XPathExpr $expr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function join($combiner, self $expr)
|
||||
{
|
||||
$path = $this->__toString().$combiner;
|
||||
|
||||
if ('*/' !== $expr->path) {
|
||||
$path .= $expr->path;
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->element = $expr->element;
|
||||
$this->condition = $expr->condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$path = $this->path.$this->element;
|
||||
$condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
|
||||
|
||||
return $path.$condition;
|
||||
}
|
||||
}
|
||||
741
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Iconv.php
vendored
Normal file
741
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Iconv.php
vendored
Normal file
@@ -0,0 +1,741 @@
|
||||
<?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 Symfony\Polyfill\Iconv;
|
||||
|
||||
/**
|
||||
* iconv implementation in pure PHP, UTF-8 centric.
|
||||
*
|
||||
* Implemented:
|
||||
* - iconv - Convert string to requested character encoding
|
||||
* - iconv_mime_decode - Decodes a MIME header field
|
||||
* - iconv_mime_decode_headers - Decodes multiple MIME header fields at once
|
||||
* - iconv_get_encoding - Retrieve internal configuration variables of iconv extension
|
||||
* - iconv_set_encoding - Set current setting for character encoding conversion
|
||||
* - iconv_mime_encode - Composes a MIME header field
|
||||
* - iconv_strlen - Returns the character count of string
|
||||
* - iconv_strpos - Finds position of first occurrence of a needle within a haystack
|
||||
* - iconv_strrpos - Finds the last occurrence of a needle within a haystack
|
||||
* - iconv_substr - Cut out part of a string
|
||||
*
|
||||
* Charsets available for conversion are defined by files
|
||||
* in the charset/ directory and by Iconv::$alias below.
|
||||
* You're welcome to send back any addition you make.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Iconv
|
||||
{
|
||||
const ERROR_ILLEGAL_CHARACTER = 'iconv(): Detected an illegal character in input string';
|
||||
const ERROR_WRONG_CHARSET = 'iconv(): Wrong charset, conversion from `%s\' to `%s\' is not allowed';
|
||||
|
||||
public static $inputEncoding = 'utf-8';
|
||||
public static $outputEncoding = 'utf-8';
|
||||
public static $internalEncoding = 'utf-8';
|
||||
|
||||
private static $alias = array(
|
||||
'utf8' => 'utf-8',
|
||||
'ascii' => 'us-ascii',
|
||||
'tis-620' => 'iso-8859-11',
|
||||
'cp1250' => 'windows-1250',
|
||||
'cp1251' => 'windows-1251',
|
||||
'cp1252' => 'windows-1252',
|
||||
'cp1253' => 'windows-1253',
|
||||
'cp1254' => 'windows-1254',
|
||||
'cp1255' => 'windows-1255',
|
||||
'cp1256' => 'windows-1256',
|
||||
'cp1257' => 'windows-1257',
|
||||
'cp1258' => 'windows-1258',
|
||||
'shift-jis' => 'cp932',
|
||||
'shift_jis' => 'cp932',
|
||||
'latin1' => 'iso-8859-1',
|
||||
'latin2' => 'iso-8859-2',
|
||||
'latin3' => 'iso-8859-3',
|
||||
'latin4' => 'iso-8859-4',
|
||||
'latin5' => 'iso-8859-9',
|
||||
'latin6' => 'iso-8859-10',
|
||||
'latin7' => 'iso-8859-13',
|
||||
'latin8' => 'iso-8859-14',
|
||||
'latin9' => 'iso-8859-15',
|
||||
'latin10' => 'iso-8859-16',
|
||||
'iso8859-1' => 'iso-8859-1',
|
||||
'iso8859-2' => 'iso-8859-2',
|
||||
'iso8859-3' => 'iso-8859-3',
|
||||
'iso8859-4' => 'iso-8859-4',
|
||||
'iso8859-5' => 'iso-8859-5',
|
||||
'iso8859-6' => 'iso-8859-6',
|
||||
'iso8859-7' => 'iso-8859-7',
|
||||
'iso8859-8' => 'iso-8859-8',
|
||||
'iso8859-9' => 'iso-8859-9',
|
||||
'iso8859-10' => 'iso-8859-10',
|
||||
'iso8859-11' => 'iso-8859-11',
|
||||
'iso8859-12' => 'iso-8859-12',
|
||||
'iso8859-13' => 'iso-8859-13',
|
||||
'iso8859-14' => 'iso-8859-14',
|
||||
'iso8859-15' => 'iso-8859-15',
|
||||
'iso8859-16' => 'iso-8859-16',
|
||||
'iso_8859-1' => 'iso-8859-1',
|
||||
'iso_8859-2' => 'iso-8859-2',
|
||||
'iso_8859-3' => 'iso-8859-3',
|
||||
'iso_8859-4' => 'iso-8859-4',
|
||||
'iso_8859-5' => 'iso-8859-5',
|
||||
'iso_8859-6' => 'iso-8859-6',
|
||||
'iso_8859-7' => 'iso-8859-7',
|
||||
'iso_8859-8' => 'iso-8859-8',
|
||||
'iso_8859-9' => 'iso-8859-9',
|
||||
'iso_8859-10' => 'iso-8859-10',
|
||||
'iso_8859-11' => 'iso-8859-11',
|
||||
'iso_8859-12' => 'iso-8859-12',
|
||||
'iso_8859-13' => 'iso-8859-13',
|
||||
'iso_8859-14' => 'iso-8859-14',
|
||||
'iso_8859-15' => 'iso-8859-15',
|
||||
'iso_8859-16' => 'iso-8859-16',
|
||||
'iso88591' => 'iso-8859-1',
|
||||
'iso88592' => 'iso-8859-2',
|
||||
'iso88593' => 'iso-8859-3',
|
||||
'iso88594' => 'iso-8859-4',
|
||||
'iso88595' => 'iso-8859-5',
|
||||
'iso88596' => 'iso-8859-6',
|
||||
'iso88597' => 'iso-8859-7',
|
||||
'iso88598' => 'iso-8859-8',
|
||||
'iso88599' => 'iso-8859-9',
|
||||
'iso885910' => 'iso-8859-10',
|
||||
'iso885911' => 'iso-8859-11',
|
||||
'iso885912' => 'iso-8859-12',
|
||||
'iso885913' => 'iso-8859-13',
|
||||
'iso885914' => 'iso-8859-14',
|
||||
'iso885915' => 'iso-8859-15',
|
||||
'iso885916' => 'iso-8859-16',
|
||||
);
|
||||
private static $translitMap = array();
|
||||
private static $convertMap = array();
|
||||
private static $errorHandler;
|
||||
private static $lastError;
|
||||
|
||||
private static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
||||
private static $isValidUtf8;
|
||||
|
||||
public static function iconv($inCharset, $outCharset, $str)
|
||||
{
|
||||
$str = (string) $str;
|
||||
if ('' === $str) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare for //IGNORE and //TRANSLIT
|
||||
|
||||
$translit = $ignore = '';
|
||||
|
||||
$outCharset = strtolower($outCharset);
|
||||
$inCharset = strtolower($inCharset);
|
||||
|
||||
if ('' === $outCharset) {
|
||||
$outCharset = 'iso-8859-1';
|
||||
}
|
||||
if ('' === $inCharset) {
|
||||
$inCharset = 'iso-8859-1';
|
||||
}
|
||||
|
||||
do {
|
||||
$loop = false;
|
||||
|
||||
if ('//translit' === substr($outCharset, -10)) {
|
||||
$loop = $translit = true;
|
||||
$outCharset = substr($outCharset, 0, -10);
|
||||
}
|
||||
|
||||
if ('//ignore' === substr($outCharset, -8)) {
|
||||
$loop = $ignore = true;
|
||||
$outCharset = substr($outCharset, 0, -8);
|
||||
}
|
||||
} while ($loop);
|
||||
|
||||
do {
|
||||
$loop = false;
|
||||
|
||||
if ('//translit' === substr($inCharset, -10)) {
|
||||
$loop = true;
|
||||
$inCharset = substr($inCharset, 0, -10);
|
||||
}
|
||||
|
||||
if ('//ignore' === substr($inCharset, -8)) {
|
||||
$loop = true;
|
||||
$inCharset = substr($inCharset, 0, -8);
|
||||
}
|
||||
} while ($loop);
|
||||
|
||||
if (isset(self::$alias[$inCharset])) {
|
||||
$inCharset = self::$alias[$inCharset];
|
||||
}
|
||||
if (isset(self::$alias[$outCharset])) {
|
||||
$outCharset = self::$alias[$outCharset];
|
||||
}
|
||||
|
||||
// Load charset maps
|
||||
|
||||
if (('utf-8' !== $inCharset && !self::loadMap('from.', $inCharset, $inMap))
|
||||
|| ('utf-8' !== $outCharset && !self::loadMap('to.', $outCharset, $outMap))) {
|
||||
trigger_error(sprintf(self::ERROR_WRONG_CHARSET, $inCharset, $outCharset));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('utf-8' !== $inCharset) {
|
||||
// Convert input to UTF-8
|
||||
$result = '';
|
||||
if (self::mapToUtf8($result, $inMap, $str, $ignore)) {
|
||||
$str = $result;
|
||||
} else {
|
||||
$str = false;
|
||||
}
|
||||
self::$isValidUtf8 = true;
|
||||
} else {
|
||||
self::$isValidUtf8 = preg_match('//u', $str);
|
||||
|
||||
if (!self::$isValidUtf8 && !$ignore) {
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('utf-8' === $outCharset) {
|
||||
// UTF-8 validation
|
||||
$str = self::utf8ToUtf8($str, $ignore);
|
||||
}
|
||||
}
|
||||
|
||||
if ('utf-8' !== $outCharset && false !== $str) {
|
||||
// Convert output to UTF-8
|
||||
$result = '';
|
||||
if (self::mapFromUtf8($result, $outMap, $str, $ignore, $translit)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function iconv_mime_decode_headers($str, $mode = 0, $charset = null)
|
||||
{
|
||||
if (null === $charset) {
|
||||
$charset = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (false !== strpos($str, "\r")) {
|
||||
$str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
|
||||
}
|
||||
$str = explode("\n\n", $str, 2);
|
||||
|
||||
$headers = array();
|
||||
|
||||
$str = preg_split('/\n(?![ \t])/', $str[0]);
|
||||
foreach ($str as $str) {
|
||||
$str = self::iconv_mime_decode($str, $mode, $charset);
|
||||
if (false === $str) {
|
||||
return false;
|
||||
}
|
||||
$str = explode(':', $str, 2);
|
||||
|
||||
if (2 === \count($str)) {
|
||||
if (isset($headers[$str[0]])) {
|
||||
if (!\is_array($headers[$str[0]])) {
|
||||
$headers[$str[0]] = array($headers[$str[0]]);
|
||||
}
|
||||
$headers[$str[0]][] = ltrim($str[1]);
|
||||
} else {
|
||||
$headers[$str[0]] = ltrim($str[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public static function iconv_mime_decode($str, $mode = 0, $charset = null)
|
||||
{
|
||||
if (null === $charset) {
|
||||
$charset = self::$internalEncoding;
|
||||
}
|
||||
if (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
|
||||
$charset .= '//IGNORE';
|
||||
}
|
||||
|
||||
if (false !== strpos($str, "\r")) {
|
||||
$str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
|
||||
}
|
||||
$str = preg_split('/\n(?![ \t])/', rtrim($str), 2);
|
||||
$str = preg_replace('/[ \t]*\n[ \t]+/', ' ', rtrim($str[0]));
|
||||
$str = preg_split('/=\?([^?]+)\?([bqBQ])\?(.*?)\?=/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
$result = self::iconv('utf-8', $charset, $str[0]);
|
||||
if (false === $result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$len = \count($str);
|
||||
|
||||
while ($i < $len) {
|
||||
$c = strtolower($str[$i]);
|
||||
if ((ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
|
||||
&& 'utf-8' !== $c
|
||||
&& !isset(self::$alias[$c])
|
||||
&& !self::loadMap('from.', $c, $d)) {
|
||||
$d = false;
|
||||
} elseif ('B' === strtoupper($str[$i + 1])) {
|
||||
$d = base64_decode($str[$i + 2]);
|
||||
} else {
|
||||
$d = rawurldecode(strtr(str_replace('%', '%25', $str[$i + 2]), '=_', '% '));
|
||||
}
|
||||
|
||||
if (false !== $d) {
|
||||
if ('' !== $d) {
|
||||
if ('' === $d = self::iconv($c, $charset, $d)) {
|
||||
$str[$i + 3] = substr($str[$i + 3], 1);
|
||||
} else {
|
||||
$result .= $d;
|
||||
}
|
||||
}
|
||||
$d = self::iconv('utf-8', $charset, $str[$i + 3]);
|
||||
if ('' !== trim($d)) {
|
||||
$result .= $d;
|
||||
}
|
||||
} elseif (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
|
||||
$result .= "=?{$str[$i]}?{$str[$i + 1]}?{$str[$i + 2]}?={$str[$i + 3]}";
|
||||
} else {
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$i += 4;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function iconv_get_encoding($type = 'all')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'input_encoding': return self::$inputEncoding;
|
||||
case 'output_encoding': return self::$outputEncoding;
|
||||
case 'internal_encoding': return self::$internalEncoding;
|
||||
}
|
||||
|
||||
return array(
|
||||
'input_encoding' => self::$inputEncoding,
|
||||
'output_encoding' => self::$outputEncoding,
|
||||
'internal_encoding' => self::$internalEncoding,
|
||||
);
|
||||
}
|
||||
|
||||
public static function iconv_set_encoding($type, $charset)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'input_encoding': self::$inputEncoding = $charset; break;
|
||||
case 'output_encoding': self::$outputEncoding = $charset; break;
|
||||
case 'internal_encoding': self::$internalEncoding = $charset; break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function iconv_mime_encode($fieldName, $fieldValue, $pref = null)
|
||||
{
|
||||
if (!\is_array($pref)) {
|
||||
$pref = array();
|
||||
}
|
||||
|
||||
$pref += array(
|
||||
'scheme' => 'B',
|
||||
'input-charset' => self::$internalEncoding,
|
||||
'output-charset' => self::$internalEncoding,
|
||||
'line-length' => 76,
|
||||
'line-break-chars' => "\r\n",
|
||||
);
|
||||
|
||||
if (preg_match('/[\x80-\xFF]/', $fieldName)) {
|
||||
$fieldName = '';
|
||||
}
|
||||
|
||||
$scheme = strtoupper(substr($pref['scheme'], 0, 1));
|
||||
$in = strtolower($pref['input-charset']);
|
||||
$out = strtolower($pref['output-charset']);
|
||||
|
||||
if ('utf-8' !== $in && false === $fieldValue = self::iconv($in, 'utf-8', $fieldValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
preg_match_all('/./us', $fieldValue, $chars);
|
||||
|
||||
$chars = isset($chars[0]) ? $chars[0] : array();
|
||||
|
||||
$lineBreak = (int) $pref['line-length'];
|
||||
$lineStart = "=?{$pref['output-charset']}?{$scheme}?";
|
||||
$lineLength = \strlen($fieldName) + 2 + \strlen($lineStart) + 2;
|
||||
$lineOffset = \strlen($lineStart) + 3;
|
||||
$lineData = '';
|
||||
|
||||
$fieldValue = array();
|
||||
|
||||
$Q = 'Q' === $scheme;
|
||||
|
||||
foreach ($chars as $c) {
|
||||
if ('utf-8' !== $out && false === $c = self::iconv('utf-8', $out, $c)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$o = $Q
|
||||
? $c = preg_replace_callback(
|
||||
'/[=_\?\x00-\x1F\x80-\xFF]/',
|
||||
array(__CLASS__, 'qpByteCallback'),
|
||||
$c
|
||||
)
|
||||
: base64_encode($lineData.$c);
|
||||
|
||||
if (isset($o[$lineBreak - $lineLength])) {
|
||||
if (!$Q) {
|
||||
$lineData = base64_encode($lineData);
|
||||
}
|
||||
$fieldValue[] = $lineStart.$lineData.'?=';
|
||||
$lineLength = $lineOffset;
|
||||
$lineData = '';
|
||||
}
|
||||
|
||||
$lineData .= $c;
|
||||
$Q && $lineLength += \strlen($c);
|
||||
}
|
||||
|
||||
if ('' !== $lineData) {
|
||||
if (!$Q) {
|
||||
$lineData = base64_encode($lineData);
|
||||
}
|
||||
$fieldValue[] = $lineStart.$lineData.'?=';
|
||||
}
|
||||
|
||||
return $fieldName.': '.implode($pref['line-break-chars'].' ', $fieldValue);
|
||||
}
|
||||
|
||||
public static function iconv_strlen($s, $encoding = null)
|
||||
{
|
||||
static $hasXml = null;
|
||||
if (null === $hasXml) {
|
||||
$hasXml = \extension_loaded('xml');
|
||||
}
|
||||
|
||||
if ($hasXml) {
|
||||
return self::strlen1($s, $encoding);
|
||||
}
|
||||
|
||||
return self::strlen2($s, $encoding);
|
||||
}
|
||||
|
||||
public static function strlen1($s, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
if (0 !== stripos($encoding, 'utf-8') && false === $s = self::iconv($encoding, 'utf-8', $s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return \strlen(utf8_decode($s));
|
||||
}
|
||||
|
||||
public static function strlen2($s, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
if (0 !== stripos($encoding, 'utf-8') && false === $s = self::iconv($encoding, 'utf-8', $s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ulenMask = self::$ulenMask;
|
||||
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
$len = \strlen($s);
|
||||
|
||||
while ($i < $len) {
|
||||
$u = $s[$i] & "\xF0";
|
||||
$i += isset($ulenMask[$u]) ? $ulenMask[$u] : 1;
|
||||
++$j;
|
||||
}
|
||||
|
||||
return $j;
|
||||
}
|
||||
|
||||
public static function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) {
|
||||
return false;
|
||||
}
|
||||
if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($offset = (int) $offset) {
|
||||
$haystack = self::iconv_substr($haystack, $offset, 2147483647, 'utf-8');
|
||||
}
|
||||
$pos = strpos($haystack, $needle);
|
||||
|
||||
return false === $pos ? false : ($offset + ($pos ? self::iconv_strlen(substr($haystack, 0, $pos), 'utf-8') : 0));
|
||||
}
|
||||
|
||||
public static function iconv_strrpos($haystack, $needle, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) {
|
||||
return false;
|
||||
}
|
||||
if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$pos = isset($needle[0]) ? strrpos($haystack, $needle) : false;
|
||||
|
||||
return false === $pos ? false : self::iconv_strlen($pos ? substr($haystack, 0, $pos) : $haystack, 'utf-8');
|
||||
}
|
||||
|
||||
public static function iconv_substr($s, $start, $length = 2147483647, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
$encoding = null;
|
||||
} elseif (false === $s = self::iconv($encoding, 'utf-8', $s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = (string) $s;
|
||||
$slen = self::iconv_strlen($s, 'utf-8');
|
||||
$start = (int) $start;
|
||||
|
||||
if (0 > $start) {
|
||||
$start += $slen;
|
||||
}
|
||||
if (0 > $start) {
|
||||
return false;
|
||||
}
|
||||
if ($start >= $slen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$rx = $slen - $start;
|
||||
|
||||
if (0 > $length) {
|
||||
$length += $rx;
|
||||
}
|
||||
if (0 === $length) {
|
||||
return '';
|
||||
}
|
||||
if (0 > $length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($length > $rx) {
|
||||
$length = $rx;
|
||||
}
|
||||
|
||||
$rx = '/^'.($start ? self::pregOffset($start) : '').'('.self::pregOffset($length).')/u';
|
||||
|
||||
$s = preg_match($rx, $s, $s) ? $s[1] : '';
|
||||
|
||||
if (null === $encoding) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
return self::iconv('utf-8', $encoding, $s);
|
||||
}
|
||||
|
||||
private static function loadMap($type, $charset, &$map)
|
||||
{
|
||||
if (!isset(self::$convertMap[$type.$charset])) {
|
||||
if (false === $map = self::getData($type.$charset)) {
|
||||
if ('to.' === $type && self::loadMap('from.', $charset, $map)) {
|
||||
$map = array_flip($map);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
self::$convertMap[$type.$charset] = $map;
|
||||
} else {
|
||||
$map = self::$convertMap[$type.$charset];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function utf8ToUtf8($str, $ignore)
|
||||
{
|
||||
$ulenMask = self::$ulenMask;
|
||||
$valid = self::$isValidUtf8;
|
||||
|
||||
$u = $str;
|
||||
$i = $j = 0;
|
||||
$len = \strlen($str);
|
||||
|
||||
while ($i < $len) {
|
||||
if ($str[$i] < "\x80") {
|
||||
$u[$j++] = $str[$i++];
|
||||
} else {
|
||||
$ulen = $str[$i] & "\xF0";
|
||||
$ulen = isset($ulenMask[$ulen]) ? $ulenMask[$ulen] : 1;
|
||||
$uchr = substr($str, $i, $ulen);
|
||||
|
||||
if (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr))) {
|
||||
if ($ignore) {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$i += $ulen;
|
||||
}
|
||||
|
||||
$u[$j++] = $uchr[0];
|
||||
|
||||
isset($uchr[1]) && 0 !== ($u[$j++] = $uchr[1])
|
||||
&& isset($uchr[2]) && 0 !== ($u[$j++] = $uchr[2])
|
||||
&& isset($uchr[3]) && 0 !== ($u[$j++] = $uchr[3]);
|
||||
}
|
||||
}
|
||||
|
||||
return substr($u, 0, $j);
|
||||
}
|
||||
|
||||
private static function mapToUtf8(&$result, array $map, $str, $ignore)
|
||||
{
|
||||
$len = \strlen($str);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
if (isset($str[$i + 1], $map[$str[$i].$str[$i + 1]])) {
|
||||
$result .= $map[$str[$i].$str[++$i]];
|
||||
} elseif (isset($map[$str[$i]])) {
|
||||
$result .= $map[$str[$i]];
|
||||
} elseif (!$ignore) {
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function mapFromUtf8(&$result, array $map, $str, $ignore, $translit)
|
||||
{
|
||||
$ulenMask = self::$ulenMask;
|
||||
$valid = self::$isValidUtf8;
|
||||
|
||||
if ($translit && !self::$translitMap) {
|
||||
self::$translitMap = self::getData('translit');
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$len = \strlen($str);
|
||||
|
||||
while ($i < $len) {
|
||||
if ($str[$i] < "\x80") {
|
||||
$uchr = $str[$i++];
|
||||
} else {
|
||||
$ulen = $str[$i] & "\xF0";
|
||||
$ulen = isset($ulenMask[$ulen]) ? $ulenMask[$ulen] : 1;
|
||||
$uchr = substr($str, $i, $ulen);
|
||||
|
||||
if ($ignore && (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr)))) {
|
||||
++$i;
|
||||
continue;
|
||||
} else {
|
||||
$i += $ulen;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($map[$uchr])) {
|
||||
$result .= $map[$uchr];
|
||||
} elseif ($translit) {
|
||||
if (isset(self::$translitMap[$uchr])) {
|
||||
$uchr = self::$translitMap[$uchr];
|
||||
} elseif ($uchr >= "\xC3\x80") {
|
||||
$uchr = \Normalizer::normalize($uchr, \Normalizer::NFD);
|
||||
|
||||
if ($uchr[0] < "\x80") {
|
||||
$uchr = $uchr[0];
|
||||
} elseif ($ignore) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ($ignore) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$str = $uchr.substr($str, $i);
|
||||
$len = \strlen($str);
|
||||
$i = 0;
|
||||
} elseif (!$ignore) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function qpByteCallback(array $m)
|
||||
{
|
||||
return '='.strtoupper(dechex(\ord($m[0])));
|
||||
}
|
||||
|
||||
private static function pregOffset($offset)
|
||||
{
|
||||
$rx = array();
|
||||
$offset = (int) $offset;
|
||||
|
||||
while ($offset > 65535) {
|
||||
$rx[] = '.{65535}';
|
||||
$offset -= 65535;
|
||||
}
|
||||
|
||||
return implode('', $rx).'.{'.$offset.'}';
|
||||
}
|
||||
|
||||
private static function getData($file)
|
||||
{
|
||||
if (file_exists($file = __DIR__.'/Resources/charset/'.$file.'.php')) {
|
||||
return require $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
19
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/LICENSE
vendored
Normal file
19
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
13719
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.big5.php
vendored
Normal file
13719
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.big5.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp037.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp037.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1006.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1006.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1026.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1026.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp424.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp424.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp437.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp437.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp500.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp500.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp737.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp737.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp775.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp775.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp850.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp850.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp852.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp852.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp855.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp855.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp856.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp856.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp857.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp857.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp860.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp860.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp861.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp861.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp862.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp862.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp863.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp863.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp864.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp864.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp865.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp865.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp866.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp866.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp869.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp869.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp874.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp874.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp875.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp875.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp932.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp932.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp936.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp936.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp949.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp949.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp950.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.cp950.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-1.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-1.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-10.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-10.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-11.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-11.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-13.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-13.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-14.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-14.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-15.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-15.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-16.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-16.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-2.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-2.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-3.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-3.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-4.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-4.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-5.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-5.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-6.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-6.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-7.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-7.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-8.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-8.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-9.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-9.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-r.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-r.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-u.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-u.php
vendored
Normal file
Binary file not shown.
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.us-ascii.php
vendored
Normal file
BIN
wp-content/plugins/wpforms-lite/vendor/symfony/polyfill-iconv/Resources/charset/from.us-ascii.php
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user