mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
➖ N°4284 remove unused dependencies
This commit is contained in:
@@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b::getLoader();
|
||||
return ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f::getLoader();
|
||||
|
||||
@@ -1172,6 +1172,8 @@ return array(
|
||||
'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php',
|
||||
'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php',
|
||||
'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php',
|
||||
'Psr\\Log\\Test\\LoggerInterfaceTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
|
||||
'Psr\\Log\\Test\\TestLogger' => $vendorDir . '/psr/log/Psr/Log/Test/TestLogger.php',
|
||||
'Psr\\SimpleCache\\CacheException' => $vendorDir . '/psr/simple-cache/src/CacheException.php',
|
||||
'Psr\\SimpleCache\\CacheInterface' => $vendorDir . '/psr/simple-cache/src/CacheInterface.php',
|
||||
'Psr\\SimpleCache\\InvalidArgumentException' => $vendorDir . '/psr/simple-cache/src/InvalidArgumentException.php',
|
||||
@@ -1433,6 +1435,9 @@ return array(
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser' => $vendorDir . '/symfony/framework-bundle/Templating/TemplateNameParser.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference' => $vendorDir . '/symfony/framework-bundle/Templating/TemplateReference.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TimedPhpEngine' => $vendorDir . '/symfony/framework-bundle/Templating/TimedPhpEngine.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\ForwardCompatTestTrait' => $vendorDir . '/symfony/framework-bundle/Test/ForwardCompatTestTrait.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase' => $vendorDir . '/symfony/framework-bundle/Test/KernelTestCase.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase' => $vendorDir . '/symfony/framework-bundle/Test/WebTestCase.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpExtractor' => $vendorDir . '/symfony/framework-bundle/Translation/PhpExtractor.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpStringTokenParser' => $vendorDir . '/symfony/framework-bundle/Translation/PhpStringTokenParser.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\TranslationLoader' => $vendorDir . '/symfony/framework-bundle/Translation/TranslationLoader.php',
|
||||
@@ -2237,6 +2242,7 @@ return array(
|
||||
'Symfony\\Component\\VarDumper\\Dumper\\DataDumperInterface' => $vendorDir . '/symfony/var-dumper/Dumper/DataDumperInterface.php',
|
||||
'Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper' => $vendorDir . '/symfony/var-dumper/Dumper/HtmlDumper.php',
|
||||
'Symfony\\Component\\VarDumper\\Exception\\ThrowingCasterException' => $vendorDir . '/symfony/var-dumper/Exception/ThrowingCasterException.php',
|
||||
'Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait' => $vendorDir . '/symfony/var-dumper/Test/VarDumperTestTrait.php',
|
||||
'Symfony\\Component\\VarDumper\\VarDumper' => $vendorDir . '/symfony/var-dumper/VarDumper.php',
|
||||
'Symfony\\Component\\Yaml\\Command\\LintCommand' => $vendorDir . '/symfony/yaml/Command/LintCommand.php',
|
||||
'Symfony\\Component\\Yaml\\Dumper' => $vendorDir . '/symfony/yaml/Dumper.php',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b
|
||||
class ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@@ -24,23 +24,23 @@ class ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f', 'loadClassLoader'));
|
||||
|
||||
$includePaths = require __DIR__ . '/include_paths.php';
|
||||
$includePaths[] = get_include_path();
|
||||
set_include_path(implode(PATH_SEPARATOR, $includePaths));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire0018331147de7601e7552f7da8e3bb8b($fileIdentifier, $file);
|
||||
composerRequire7f81b4a2a468a061c306af5e447a9a9f($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@@ -52,7 +52,7 @@ class ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire0018331147de7601e7552f7da8e3bb8b($fileIdentifier, $file)
|
||||
function composerRequire7f81b4a2a468a061c306af5e447a9a9f($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@@ -1453,6 +1453,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php',
|
||||
'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php',
|
||||
'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php',
|
||||
'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
|
||||
'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php',
|
||||
'Psr\\SimpleCache\\CacheException' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheException.php',
|
||||
'Psr\\SimpleCache\\CacheInterface' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheInterface.php',
|
||||
'Psr\\SimpleCache\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/simple-cache/src/InvalidArgumentException.php',
|
||||
@@ -1714,6 +1716,9 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TemplateNameParser.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TemplateReference.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TimedPhpEngine' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TimedPhpEngine.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\ForwardCompatTestTrait' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/ForwardCompatTestTrait.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/KernelTestCase.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/WebTestCase.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpExtractor' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/PhpExtractor.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpStringTokenParser' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/PhpStringTokenParser.php',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Translation\\TranslationLoader' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/TranslationLoader.php',
|
||||
@@ -2518,6 +2523,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'Symfony\\Component\\VarDumper\\Dumper\\DataDumperInterface' => __DIR__ . '/..' . '/symfony/var-dumper/Dumper/DataDumperInterface.php',
|
||||
'Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper' => __DIR__ . '/..' . '/symfony/var-dumper/Dumper/HtmlDumper.php',
|
||||
'Symfony\\Component\\VarDumper\\Exception\\ThrowingCasterException' => __DIR__ . '/..' . '/symfony/var-dumper/Exception/ThrowingCasterException.php',
|
||||
'Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait' => __DIR__ . '/..' . '/symfony/var-dumper/Test/VarDumperTestTrait.php',
|
||||
'Symfony\\Component\\VarDumper\\VarDumper' => __DIR__ . '/..' . '/symfony/var-dumper/VarDumper.php',
|
||||
'Symfony\\Component\\Yaml\\Command\\LintCommand' => __DIR__ . '/..' . '/symfony/yaml/Command/LintCommand.php',
|
||||
'Symfony\\Component\\Yaml\\Dumper' => __DIR__ . '/..' . '/symfony/yaml/Dumper.php',
|
||||
@@ -3063,11 +3069,11 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$prefixesPsr0;
|
||||
$loader->fallbackDirsPsr0 = ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$fallbackDirsPsr0;
|
||||
$loader->classMap = ComposerStaticInit0018331147de7601e7552f7da8e3bb8b::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$prefixesPsr0;
|
||||
$loader->fallbackDirsPsr0 = ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$fallbackDirsPsr0;
|
||||
$loader->classMap = ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ $vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$vendorDir . '/pear/archive_tar',
|
||||
$vendorDir . '/pear/pear_exception',
|
||||
$vendorDir . '/pear/console_getopt',
|
||||
$vendorDir . '/pear/pear-core-minimal/src',
|
||||
$vendorDir . '/pear/pear_exception',
|
||||
$vendorDir . '/pear/archive_tar',
|
||||
);
|
||||
|
||||
@@ -871,6 +871,10 @@
|
||||
}
|
||||
],
|
||||
"description": "More info available on: http://pear.php.net/package/Console_Getopt",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_Getopt",
|
||||
"source": "https://github.com/pear/Console_Getopt"
|
||||
},
|
||||
"install-path": "../pear/console_getopt"
|
||||
},
|
||||
{
|
||||
@@ -918,6 +922,10 @@
|
||||
}
|
||||
],
|
||||
"description": "Minimal set of PEAR core files to be used as composer dependency",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR",
|
||||
"source": "https://github.com/pear/pear-core-minimal"
|
||||
},
|
||||
"install-path": "../pear/pear-core-minimal"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '56f8f9b38d649bb36bca6d4bdc35719862ef7cad',
|
||||
'reference' => 'fa5644064a3cd6306b4bc044ad8b88ec3d659088',
|
||||
'name' => '__root__',
|
||||
'dev' => true,
|
||||
),
|
||||
@@ -16,7 +16,7 @@
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '56f8f9b38d649bb36bca6d4bdc35719862ef7cad',
|
||||
'reference' => 'fa5644064a3cd6306b4bc044ad8b88ec3d659088',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'combodo/tcpdf' => array(
|
||||
@@ -196,8 +196,8 @@
|
||||
'psr/container-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '1.0',
|
||||
1 => '^1.0',
|
||||
0 => '^1.0',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/log' => array(
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2006-2018 Doctrine Project
|
||||
|
||||
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.
|
||||
@@ -1,9 +0,0 @@
|
||||
# Doctrine Lexer
|
||||
|
||||
[](https://github.com/doctrine/lexer/actions)
|
||||
|
||||
Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
|
||||
|
||||
This lexer is used in Doctrine Annotations and in Doctrine ORM (DQL).
|
||||
|
||||
https://www.doctrine-project.org/projects/lexer.html
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"type": "library",
|
||||
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"keywords": [
|
||||
"php",
|
||||
"parser",
|
||||
"lexer",
|
||||
"annotations",
|
||||
"docblock"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^9.0",
|
||||
"phpstan/phpstan": "^1.3",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||
"vimeo/psalm": "^4.11"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Doctrine\\Tests\\": "tests/Doctrine" }
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Lexer;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function preg_split;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
use const PREG_SPLIT_NO_EMPTY;
|
||||
use const PREG_SPLIT_OFFSET_CAPTURE;
|
||||
|
||||
/**
|
||||
* Base class for writing simple lexers, i.e. for creating small DSLs.
|
||||
*
|
||||
* @psalm-type Token = array{value: int|string, type:string|int|null, position:int}
|
||||
*/
|
||||
abstract class AbstractLexer
|
||||
{
|
||||
/**
|
||||
* Lexer original input string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $input;
|
||||
|
||||
/**
|
||||
* Array of scanned tokens.
|
||||
*
|
||||
* Each token is an associative array containing three items:
|
||||
* - 'value' : the string value of the token in the input string
|
||||
* - 'type' : the type of the token (identifier, numeric, string, input
|
||||
* parameter, none)
|
||||
* - 'position' : the position of the token in the input string
|
||||
*
|
||||
* @var mixed[][]
|
||||
* @psalm-var list<Token>
|
||||
*/
|
||||
private $tokens = [];
|
||||
|
||||
/**
|
||||
* Current lexer position in input string.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $position = 0;
|
||||
|
||||
/**
|
||||
* Current peek of current lexer position.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $peek = 0;
|
||||
|
||||
/**
|
||||
* The next token in the input.
|
||||
*
|
||||
* @var mixed[]|null
|
||||
* @psalm-var Token|null
|
||||
*/
|
||||
public $lookahead;
|
||||
|
||||
/**
|
||||
* The last matched/seen token.
|
||||
*
|
||||
* @var mixed[]|null
|
||||
* @psalm-var Token|null
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* Composed regex for input parsing.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $regex;
|
||||
|
||||
/**
|
||||
* Sets the input data to be tokenized.
|
||||
*
|
||||
* The Lexer is immediately reset and the new input tokenized.
|
||||
* Any unprocessed tokens from any previous input are lost.
|
||||
*
|
||||
* @param string $input The input to be tokenized.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setInput($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->tokens = [];
|
||||
|
||||
$this->reset();
|
||||
$this->scan($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the lexer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->lookahead = null;
|
||||
$this->token = null;
|
||||
$this->peek = 0;
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the peek pointer to 0.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetPeek()
|
||||
{
|
||||
$this->peek = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the lexer position on the input to the given position.
|
||||
*
|
||||
* @param int $position Position to place the lexical scanner.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetPosition($position = 0)
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the original lexer's input until a given position.
|
||||
*
|
||||
* @param int $position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputUntilPosition($position)
|
||||
{
|
||||
return substr($this->input, 0, $position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given token matches the current lookahead.
|
||||
*
|
||||
* @param int|string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNextToken($type)
|
||||
{
|
||||
return $this->lookahead !== null && $this->lookahead['type'] === $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether any of the given tokens matches the current lookahead.
|
||||
*
|
||||
* @param list<int|string> $types
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNextTokenAny(array $types)
|
||||
{
|
||||
return $this->lookahead !== null && in_array($this->lookahead['type'], $types, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves to the next token in the input string.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveNext()
|
||||
{
|
||||
$this->peek = 0;
|
||||
$this->token = $this->lookahead;
|
||||
$this->lookahead = isset($this->tokens[$this->position])
|
||||
? $this->tokens[$this->position++] : null;
|
||||
|
||||
return $this->lookahead !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the lexer to skip input tokens until it sees a token with the given value.
|
||||
*
|
||||
* @param string $type The token type to skip until.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function skipUntil($type)
|
||||
{
|
||||
while ($this->lookahead !== null && $this->lookahead['type'] !== $type) {
|
||||
$this->moveNext();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if given value is identical to the given token.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param int|string $token
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isA($value, $token)
|
||||
{
|
||||
return $this->getType($value) === $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the lookahead token forward.
|
||||
*
|
||||
* @return mixed[]|null The next token or NULL if there are no more tokens ahead.
|
||||
* @psalm-return Token|null
|
||||
*/
|
||||
public function peek()
|
||||
{
|
||||
if (isset($this->tokens[$this->position + $this->peek])) {
|
||||
return $this->tokens[$this->position + $this->peek++];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Peeks at the next token, returns it and immediately resets the peek.
|
||||
*
|
||||
* @return mixed[]|null The next token or NULL if there are no more tokens ahead.
|
||||
* @psalm-return Token|null
|
||||
*/
|
||||
public function glimpse()
|
||||
{
|
||||
$peek = $this->peek();
|
||||
$this->peek = 0;
|
||||
|
||||
return $peek;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the input string for tokens.
|
||||
*
|
||||
* @param string $input A query string.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function scan($input)
|
||||
{
|
||||
if (! isset($this->regex)) {
|
||||
$this->regex = sprintf(
|
||||
'/(%s)|%s/%s',
|
||||
implode(')|(', $this->getCatchablePatterns()),
|
||||
implode('|', $this->getNonCatchablePatterns()),
|
||||
$this->getModifiers()
|
||||
);
|
||||
}
|
||||
|
||||
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
|
||||
$matches = preg_split($this->regex, $input, -1, $flags);
|
||||
|
||||
if ($matches === false) {
|
||||
// Work around https://bugs.php.net/78122
|
||||
$matches = [[$input, 0]];
|
||||
}
|
||||
|
||||
foreach ($matches as $match) {
|
||||
// Must remain before 'value' assignment since it can change content
|
||||
$type = $this->getType($match[0]);
|
||||
|
||||
$this->tokens[] = [
|
||||
'value' => $match[0],
|
||||
'type' => $type,
|
||||
'position' => $match[1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the literal for a given token.
|
||||
*
|
||||
* @param int|string $token
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getLiteral($token)
|
||||
{
|
||||
$className = static::class;
|
||||
$reflClass = new ReflectionClass($className);
|
||||
$constants = $reflClass->getConstants();
|
||||
|
||||
foreach ($constants as $name => $value) {
|
||||
if ($value === $token) {
|
||||
return $className . '::' . $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regex modifiers
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getModifiers()
|
||||
{
|
||||
return 'iu';
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract protected function getCatchablePatterns();
|
||||
|
||||
/**
|
||||
* Lexical non-catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract protected function getNonCatchablePatterns();
|
||||
|
||||
/**
|
||||
* Retrieve token type. Also processes the token value if necessary.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return int|string|null
|
||||
*/
|
||||
abstract protected function getType(&$value);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="5"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib/Doctrine/Common/Lexer" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2013-2016 Eduardo Gulias Davis
|
||||
|
||||
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.
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"description": "A library for validating emails against several RFCs",
|
||||
"homepage": "https://github.com/egulias/EmailValidator",
|
||||
"keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Eduardo Gulias Davis"}
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1.x-dev"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"doctrine/lexer": "^1.0.1",
|
||||
"symfony/polyfill-intl-idn": "^1.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"dominicsayers/isemail": "^3.0.7",
|
||||
"phpunit/phpunit": "^4.8.36|^7.5.15",
|
||||
"satooshi/php-coveralls": "^1.0.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\Tests\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
class EmailLexer extends AbstractLexer
|
||||
{
|
||||
//ASCII values
|
||||
const C_DEL = 127;
|
||||
const C_NUL = 0;
|
||||
const S_AT = 64;
|
||||
const S_BACKSLASH = 92;
|
||||
const S_DOT = 46;
|
||||
const S_DQUOTE = 34;
|
||||
const S_SQUOTE = 39;
|
||||
const S_BACKTICK = 96;
|
||||
const S_OPENPARENTHESIS = 49;
|
||||
const S_CLOSEPARENTHESIS = 261;
|
||||
const S_OPENBRACKET = 262;
|
||||
const S_CLOSEBRACKET = 263;
|
||||
const S_HYPHEN = 264;
|
||||
const S_COLON = 265;
|
||||
const S_DOUBLECOLON = 266;
|
||||
const S_SP = 267;
|
||||
const S_HTAB = 268;
|
||||
const S_CR = 269;
|
||||
const S_LF = 270;
|
||||
const S_IPV6TAG = 271;
|
||||
const S_LOWERTHAN = 272;
|
||||
const S_GREATERTHAN = 273;
|
||||
const S_COMMA = 274;
|
||||
const S_SEMICOLON = 275;
|
||||
const S_OPENQBRACKET = 276;
|
||||
const S_CLOSEQBRACKET = 277;
|
||||
const S_SLASH = 278;
|
||||
const S_EMPTY = null;
|
||||
const GENERIC = 300;
|
||||
const CRLF = 301;
|
||||
const INVALID = 302;
|
||||
const ASCII_INVALID_FROM = 127;
|
||||
const ASCII_INVALID_TO = 199;
|
||||
|
||||
/**
|
||||
* US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $charValue = array(
|
||||
'(' => self::S_OPENPARENTHESIS,
|
||||
')' => self::S_CLOSEPARENTHESIS,
|
||||
'<' => self::S_LOWERTHAN,
|
||||
'>' => self::S_GREATERTHAN,
|
||||
'[' => self::S_OPENBRACKET,
|
||||
']' => self::S_CLOSEBRACKET,
|
||||
':' => self::S_COLON,
|
||||
';' => self::S_SEMICOLON,
|
||||
'@' => self::S_AT,
|
||||
'\\' => self::S_BACKSLASH,
|
||||
'/' => self::S_SLASH,
|
||||
',' => self::S_COMMA,
|
||||
'.' => self::S_DOT,
|
||||
"'" => self::S_SQUOTE,
|
||||
"`" => self::S_BACKTICK,
|
||||
'"' => self::S_DQUOTE,
|
||||
'-' => self::S_HYPHEN,
|
||||
'::' => self::S_DOUBLECOLON,
|
||||
' ' => self::S_SP,
|
||||
"\t" => self::S_HTAB,
|
||||
"\r" => self::S_CR,
|
||||
"\n" => self::S_LF,
|
||||
"\r\n" => self::CRLF,
|
||||
'IPv6' => self::S_IPV6TAG,
|
||||
'{' => self::S_OPENQBRACKET,
|
||||
'}' => self::S_CLOSEQBRACKET,
|
||||
'' => self::S_EMPTY,
|
||||
'\0' => self::C_NUL,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasInvalidTokens = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @psalm-var array{value:string, type:null|int, position:int}|array<empty, empty>
|
||||
*/
|
||||
protected $previous = [];
|
||||
|
||||
/**
|
||||
* The last matched/seen token.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @psalm-var array{value:string, type:null|int, position:int}
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* The next token in the input.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $lookahead;
|
||||
|
||||
/**
|
||||
* @psalm-var array{value:'', type:null, position:0}
|
||||
*/
|
||||
private static $nullToken = [
|
||||
'value' => '',
|
||||
'type' => null,
|
||||
'position' => 0,
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->previous = $this->token = self::$nullToken;
|
||||
$this->lookahead = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->hasInvalidTokens = false;
|
||||
parent::reset();
|
||||
$this->previous = $this->token = self::$nullToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasInvalidTokens()
|
||||
{
|
||||
return $this->hasInvalidTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @throws \UnexpectedValueException
|
||||
* @return boolean
|
||||
*
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
public function find($type)
|
||||
{
|
||||
$search = clone $this;
|
||||
$search->skipUntil($type);
|
||||
|
||||
if (!$search->lookahead) {
|
||||
throw new \UnexpectedValueException($type . ' not found');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* getPrevious
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrevious()
|
||||
{
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* moveNext
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveNext()
|
||||
{
|
||||
$this->previous = $this->token;
|
||||
$hasNext = parent::moveNext();
|
||||
$this->token = $this->token ?: self::$nullToken;
|
||||
|
||||
return $hasNext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getCatchablePatterns()
|
||||
{
|
||||
return array(
|
||||
'[a-zA-Z_]+[46]?', //ASCII and domain literal
|
||||
'[^\x00-\x7F]', //UTF-8
|
||||
'[0-9]+',
|
||||
'\r\n',
|
||||
'::',
|
||||
'\s+?',
|
||||
'.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical non-catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getNonCatchablePatterns()
|
||||
{
|
||||
return array('[\xA0-\xff]+');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve token type. Also processes the token value if necessary.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws \InvalidArgumentException
|
||||
* @return integer
|
||||
*/
|
||||
protected function getType(&$value)
|
||||
{
|
||||
if ($this->isNullType($value)) {
|
||||
return self::C_NUL;
|
||||
}
|
||||
|
||||
if ($this->isValid($value)) {
|
||||
return $this->charValue[$value];
|
||||
}
|
||||
|
||||
if ($this->isUTF8Invalid($value)) {
|
||||
$this->hasInvalidTokens = true;
|
||||
return self::INVALID;
|
||||
}
|
||||
|
||||
return self::GENERIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValid($value)
|
||||
{
|
||||
if (isset($this->charValue[$value])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNullType($value)
|
||||
{
|
||||
if ($value === "\0") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUTF8Invalid($value)
|
||||
{
|
||||
if (preg_match('/\p{Cc}+/u', $value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getModifiers()
|
||||
{
|
||||
return 'iu';
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\NoLocalPart;
|
||||
use Egulias\EmailValidator\Parser\DomainPart;
|
||||
use Egulias\EmailValidator\Parser\LocalPart;
|
||||
use Egulias\EmailValidator\Warning\EmailTooLong;
|
||||
|
||||
/**
|
||||
* EmailParser
|
||||
*
|
||||
* @author Eduardo Gulias Davis <me@egulias.com>
|
||||
*/
|
||||
class EmailParser
|
||||
{
|
||||
const EMAIL_MAX_LENGTH = 254;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $warnings = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $domainPart = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $localPart = '';
|
||||
/**
|
||||
* @var EmailLexer
|
||||
*/
|
||||
protected $lexer;
|
||||
|
||||
/**
|
||||
* @var LocalPart
|
||||
*/
|
||||
protected $localPartParser;
|
||||
|
||||
/**
|
||||
* @var DomainPart
|
||||
*/
|
||||
protected $domainPartParser;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
$this->localPartParser = new LocalPart($this->lexer);
|
||||
$this->domainPartParser = new DomainPart($this->lexer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @return array
|
||||
*/
|
||||
public function parse($str)
|
||||
{
|
||||
$this->lexer->setInput($str);
|
||||
|
||||
if (!$this->hasAtToken()) {
|
||||
throw new NoLocalPart();
|
||||
}
|
||||
|
||||
|
||||
$this->localPartParser->parse($str);
|
||||
$this->domainPartParser->parse($str);
|
||||
|
||||
$this->setParts($str);
|
||||
|
||||
if ($this->lexer->hasInvalidTokens()) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
return array('local' => $this->localPart, 'domain' => $this->domainPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Warning\Warning[]
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
$localPartWarnings = $this->localPartParser->getWarnings();
|
||||
$domainPartWarnings = $this->domainPartParser->getWarnings();
|
||||
$this->warnings = array_merge($localPartWarnings, $domainPartWarnings);
|
||||
|
||||
$this->addLongEmailWarning($this->localPart, $this->domainPart);
|
||||
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getParsedDomainPart()
|
||||
{
|
||||
return $this->domainPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
protected function setParts($email)
|
||||
{
|
||||
$parts = explode('@', $email);
|
||||
$this->domainPart = $this->domainPartParser->getDomainPart();
|
||||
$this->localPart = $parts[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasAtToken()
|
||||
{
|
||||
$this->lexer->moveNext();
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $localPart
|
||||
* @param string $parsedDomainPart
|
||||
*/
|
||||
protected function addLongEmailWarning($localPart, $parsedDomainPart)
|
||||
{
|
||||
if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) {
|
||||
$this->warnings[EmailTooLong::CODE] = new EmailTooLong();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\EmailValidation;
|
||||
|
||||
class EmailValidator
|
||||
{
|
||||
/**
|
||||
* @var EmailLexer
|
||||
*/
|
||||
private $lexer;
|
||||
|
||||
/**
|
||||
* @var Warning\Warning[]
|
||||
*/
|
||||
protected $warnings = [];
|
||||
|
||||
/**
|
||||
* @var InvalidEmail|null
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->lexer = new EmailLexer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @param EmailValidation $emailValidation
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($email, EmailValidation $emailValidation)
|
||||
{
|
||||
$isValid = $emailValidation->isValid($email, $this->lexer);
|
||||
$this->warnings = $emailValidation->getWarnings();
|
||||
$this->error = $emailValidation->getError();
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasWarnings()
|
||||
{
|
||||
return !empty($this->warnings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvalidEmail|null
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class AtextAfterCFWS extends InvalidEmail
|
||||
{
|
||||
const CODE = 133;
|
||||
const REASON = "ATEXT found after CFWS";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRLFAtTheEnd extends InvalidEmail
|
||||
{
|
||||
const CODE = 149;
|
||||
const REASON = "CRLF at the end";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRLFX2 extends InvalidEmail
|
||||
{
|
||||
const CODE = 148;
|
||||
const REASON = "Folding whitespace CR LF found twice";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRNoLF extends InvalidEmail
|
||||
{
|
||||
const CODE = 150;
|
||||
const REASON = "Missing LF after CR";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CharNotAllowed extends InvalidEmail
|
||||
{
|
||||
const CODE = 201;
|
||||
const REASON = "Non allowed character in domain";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CommaInDomain extends InvalidEmail
|
||||
{
|
||||
const CODE = 200;
|
||||
const REASON = "Comma ',' is not allowed in domain part";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ConsecutiveAt extends InvalidEmail
|
||||
{
|
||||
const CODE = 128;
|
||||
const REASON = "Consecutive AT";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ConsecutiveDot extends InvalidEmail
|
||||
{
|
||||
const CODE = 132;
|
||||
const REASON = "Consecutive DOT";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DomainAcceptsNoMail extends InvalidEmail
|
||||
{
|
||||
const CODE = 154;
|
||||
const REASON = 'Domain accepts no mail (Null MX, RFC7505)';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DomainHyphened extends InvalidEmail
|
||||
{
|
||||
const CODE = 144;
|
||||
const REASON = "Hyphen found in domain";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DotAtEnd extends InvalidEmail
|
||||
{
|
||||
const CODE = 142;
|
||||
const REASON = "Dot at the end";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DotAtStart extends InvalidEmail
|
||||
{
|
||||
const CODE = 141;
|
||||
const REASON = "Found DOT at start";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingAT extends InvalidEmail
|
||||
{
|
||||
const CODE = 202;
|
||||
const REASON = "Expecting AT '@' ";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingATEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 137;
|
||||
const REASON = "Expecting ATEXT";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingCTEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 139;
|
||||
const REASON = "Expecting CTEXT";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingDTEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 129;
|
||||
const REASON = "Expected DTEXT";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingDomainLiteralClose extends InvalidEmail
|
||||
{
|
||||
const CODE = 137;
|
||||
const REASON = "Closing bracket ']' for domain literal not found";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingQPair extends InvalidEmail
|
||||
{
|
||||
const CODE = 136;
|
||||
const REASON = "Expecting QPAIR";
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
abstract class InvalidEmail extends \InvalidArgumentException
|
||||
{
|
||||
const REASON = "Invalid email";
|
||||
const CODE = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(static::REASON, static::CODE);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class LocalOrReservedDomain extends InvalidEmail
|
||||
{
|
||||
const CODE = 153;
|
||||
const REASON = 'Local, mDNS or reserved domain (RFC2606, RFC6762)';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class NoDNSRecord extends InvalidEmail
|
||||
{
|
||||
const CODE = 5;
|
||||
const REASON = 'No MX or A DSN record was found for this email';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class NoDomainPart extends InvalidEmail
|
||||
{
|
||||
const CODE = 131;
|
||||
const REASON = "No Domain part";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class NoLocalPart extends InvalidEmail
|
||||
{
|
||||
const CODE = 130;
|
||||
const REASON = "No local part";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnclosedComment extends InvalidEmail
|
||||
{
|
||||
const CODE = 146;
|
||||
const REASON = "No closing comment token found";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnclosedQuotedString extends InvalidEmail
|
||||
{
|
||||
const CODE = 145;
|
||||
const REASON = "Unclosed quoted string";
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnopenedComment extends InvalidEmail
|
||||
{
|
||||
const CODE = 152;
|
||||
const REASON = "No opening comment token found";
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\CharNotAllowed;
|
||||
use Egulias\EmailValidator\Exception\CommaInDomain;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\CRLFAtTheEnd;
|
||||
use Egulias\EmailValidator\Exception\CRNoLF;
|
||||
use Egulias\EmailValidator\Exception\DomainHyphened;
|
||||
use Egulias\EmailValidator\Exception\DotAtEnd;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDomainLiteralClose;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\AddressLiteral;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\DeprecatedComment;
|
||||
use Egulias\EmailValidator\Warning\DomainLiteral;
|
||||
use Egulias\EmailValidator\Warning\DomainTooLong;
|
||||
use Egulias\EmailValidator\Warning\IPV6BadChar;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonEnd;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonStart;
|
||||
use Egulias\EmailValidator\Warning\IPV6Deprecated;
|
||||
use Egulias\EmailValidator\Warning\IPV6DoubleColon;
|
||||
use Egulias\EmailValidator\Warning\IPV6GroupCount;
|
||||
use Egulias\EmailValidator\Warning\IPV6MaxGroups;
|
||||
use Egulias\EmailValidator\Warning\LabelTooLong;
|
||||
use Egulias\EmailValidator\Warning\ObsoleteDTEXT;
|
||||
use Egulias\EmailValidator\Warning\TLD;
|
||||
|
||||
class DomainPart extends Parser
|
||||
{
|
||||
const DOMAIN_MAX_LENGTH = 254;
|
||||
const LABEL_MAX_LENGTH = 63;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $domainPart = '';
|
||||
|
||||
public function parse($domainPart)
|
||||
{
|
||||
$this->lexer->moveNext();
|
||||
|
||||
$this->performDomainStartChecks();
|
||||
|
||||
$domain = $this->doParseDomainPart();
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
$length = strlen($domain);
|
||||
|
||||
if ($prev['type'] === EmailLexer::S_DOT) {
|
||||
throw new DotAtEnd();
|
||||
}
|
||||
if ($prev['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
if ($length > self::DOMAIN_MAX_LENGTH) {
|
||||
$this->warnings[DomainTooLong::CODE] = new DomainTooLong();
|
||||
}
|
||||
if ($prev['type'] === EmailLexer::S_CR) {
|
||||
throw new CRLFAtTheEnd();
|
||||
}
|
||||
$this->domainPart = $domain;
|
||||
}
|
||||
|
||||
private function performDomainStartChecks()
|
||||
{
|
||||
$this->checkInvalidTokensAfterAT();
|
||||
$this->checkEmptyDomain();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
||||
$this->parseDomainComments();
|
||||
}
|
||||
}
|
||||
|
||||
private function checkEmptyDomain()
|
||||
{
|
||||
$thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY ||
|
||||
($this->lexer->token['type'] === EmailLexer::S_SP &&
|
||||
!$this->lexer->isNextToken(EmailLexer::GENERIC));
|
||||
|
||||
if ($thereIsNoDomain) {
|
||||
throw new NoDomainPart();
|
||||
}
|
||||
}
|
||||
|
||||
private function checkInvalidTokensAfterAT()
|
||||
{
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
||||
throw new DotAtStart();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDomainPart()
|
||||
{
|
||||
return $this->domainPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $addressLiteral
|
||||
* @param int $maxGroups
|
||||
*/
|
||||
public function checkIPV6Tag($addressLiteral, $maxGroups = 8)
|
||||
{
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($prev['type'] === EmailLexer::S_COLON) {
|
||||
$this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd();
|
||||
}
|
||||
|
||||
$IPv6 = substr($addressLiteral, 5);
|
||||
//Daniel Marschall's new IPv6 testing strategy
|
||||
$matchesIP = explode(':', $IPv6);
|
||||
$groupCount = count($matchesIP);
|
||||
$colons = strpos($IPv6, '::');
|
||||
|
||||
if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) {
|
||||
$this->warnings[IPV6BadChar::CODE] = new IPV6BadChar();
|
||||
}
|
||||
|
||||
if ($colons === false) {
|
||||
// We need exactly the right number of groups
|
||||
if ($groupCount !== $maxGroups) {
|
||||
$this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($colons !== strrpos($IPv6, '::')) {
|
||||
$this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($colons === 0 || $colons === (strlen($IPv6) - 2)) {
|
||||
// RFC 4291 allows :: at the start or end of an address
|
||||
//with 7 other groups in addition
|
||||
++$maxGroups;
|
||||
}
|
||||
|
||||
if ($groupCount > $maxGroups) {
|
||||
$this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups();
|
||||
} elseif ($groupCount === $maxGroups) {
|
||||
$this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function doParseDomainPart()
|
||||
{
|
||||
$domain = '';
|
||||
$label = '';
|
||||
$openedParenthesis = 0;
|
||||
do {
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
$this->checkNotAllowedChars($this->lexer->token);
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
$this->lexer->moveNext();
|
||||
$tmpPrev = $this->lexer->getPrevious();
|
||||
if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
throw new UnopenedComment();
|
||||
} else {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkConsecutiveDots();
|
||||
$this->checkDomainPartExceptions($prev);
|
||||
|
||||
if ($this->hasBrackets()) {
|
||||
$this->parseDomainLiteral();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
||||
$this->checkLabelLength($label);
|
||||
$label = '';
|
||||
} else {
|
||||
$label .= $this->lexer->token['value'];
|
||||
}
|
||||
|
||||
if ($this->isFWS()) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
$domain .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SP) {
|
||||
throw new CharNotAllowed();
|
||||
}
|
||||
} while (null !== $this->lexer->token['type']);
|
||||
|
||||
$this->checkLabelLength($label);
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
||||
private function checkNotAllowedChars(array $token)
|
||||
{
|
||||
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
|
||||
if (isset($notAllowed[$token['type']])) {
|
||||
throw new CharNotAllowed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|false
|
||||
*/
|
||||
protected function parseDomainLiteral()
|
||||
{
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_COLON)) {
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) {
|
||||
$lexer = clone $this->lexer;
|
||||
$lexer->moveNext();
|
||||
if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) {
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doParseDomainLiteral();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|false
|
||||
*/
|
||||
protected function doParseDomainLiteral()
|
||||
{
|
||||
$IPv6TAG = false;
|
||||
$addressLiteral = '';
|
||||
do {
|
||||
if ($this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new ExpectingDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::INVALID ||
|
||||
$this->lexer->token['type'] === EmailLexer::C_DEL ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF
|
||||
) {
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||
throw new ExpectingDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextTokenAny(
|
||||
array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF)
|
||||
)) {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_CR)) {
|
||||
throw new CRNoLF();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
$this->validateQuotedPair();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) {
|
||||
$IPv6TAG = true;
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) {
|
||||
break;
|
||||
}
|
||||
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
|
||||
} while ($this->lexer->moveNext());
|
||||
|
||||
$addressLiteral = str_replace('[', '', $addressLiteral);
|
||||
$addressLiteral = $this->checkIPV4Tag($addressLiteral);
|
||||
|
||||
if (false === $addressLiteral) {
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
if (!$IPv6TAG) {
|
||||
$this->warnings[DomainLiteral::CODE] = new DomainLiteral();
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
|
||||
$this->checkIPV6Tag($addressLiteral);
|
||||
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $addressLiteral
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
protected function checkIPV4Tag($addressLiteral)
|
||||
{
|
||||
$matchesIP = array();
|
||||
|
||||
// Extract IPv4 part from the end of the address-literal (if there is one)
|
||||
if (preg_match(
|
||||
'/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/',
|
||||
$addressLiteral,
|
||||
$matchesIP
|
||||
) > 0
|
||||
) {
|
||||
$index = strrpos($addressLiteral, $matchesIP[0]);
|
||||
if ($index === 0) {
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
return false;
|
||||
}
|
||||
// Convert IPv4 part to IPv6 format for further testing
|
||||
$addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0';
|
||||
}
|
||||
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
protected function checkDomainPartExceptions(array $prev)
|
||||
{
|
||||
$invalidDomainTokens = array(
|
||||
EmailLexer::S_DQUOTE => true,
|
||||
EmailLexer::S_SQUOTE => true,
|
||||
EmailLexer::S_BACKTICK => true,
|
||||
EmailLexer::S_SEMICOLON => true,
|
||||
EmailLexer::S_GREATERTHAN => true,
|
||||
EmailLexer::S_LOWERTHAN => true,
|
||||
);
|
||||
|
||||
if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
|
||||
throw new CommaInDomain();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new ConsecutiveAt();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
|
||||
&& $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasBrackets()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEBRACKET);
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new ExpectingDomainLiteralClose();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
*/
|
||||
protected function checkLabelLength($label)
|
||||
{
|
||||
if ($this->isLabelTooLong($label)) {
|
||||
$this->warnings[LabelTooLong::CODE] = new LabelTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
* @return bool
|
||||
*/
|
||||
private function isLabelTooLong($label)
|
||||
{
|
||||
if (preg_match('/[^\x00-\x7F]/', $label)) {
|
||||
idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
|
||||
|
||||
return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG);
|
||||
}
|
||||
|
||||
return strlen($label) > self::LABEL_MAX_LENGTH;
|
||||
}
|
||||
|
||||
protected function parseDomainComments()
|
||||
{
|
||||
$this->isUnclosedComment();
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
$this->warnEscaping();
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
protected function addTLDWarnings()
|
||||
{
|
||||
if ($this->warnings[DomainLiteral::CODE]) {
|
||||
$this->warnings[TLD::CODE] = new TLD();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\Exception\DotAtEnd;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\ExpectingAT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\LocalTooLong;
|
||||
|
||||
class LocalPart extends Parser
|
||||
{
|
||||
public function parse($localPart)
|
||||
{
|
||||
$parseDQuote = true;
|
||||
$closingQuote = false;
|
||||
$openedParenthesis = 0;
|
||||
$totalLength = 0;
|
||||
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) {
|
||||
throw new DotAtStart();
|
||||
}
|
||||
|
||||
$closingQuote = $this->checkDQUOTE($closingQuote);
|
||||
if ($closingQuote && $parseDQuote) {
|
||||
$parseDQuote = $this->parseDoubleQuote();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
throw new UnopenedComment();
|
||||
}
|
||||
|
||||
$openedParenthesis--;
|
||||
}
|
||||
|
||||
$this->checkConsecutiveDots();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$this->lexer->isNextToken(EmailLexer::S_AT)
|
||||
) {
|
||||
throw new DotAtEnd();
|
||||
}
|
||||
|
||||
$this->warnEscaping();
|
||||
$this->isInvalidToken($this->lexer->token, $closingQuote);
|
||||
|
||||
if ($this->isFWS()) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
$totalLength += strlen($this->lexer->token['value']);
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function parseDoubleQuote()
|
||||
{
|
||||
$parseAgain = true;
|
||||
$special = array(
|
||||
EmailLexer::S_CR => true,
|
||||
EmailLexer::S_HTAB => true,
|
||||
EmailLexer::S_LF => true
|
||||
);
|
||||
|
||||
$invalid = array(
|
||||
EmailLexer::C_NUL => true,
|
||||
EmailLexer::S_HTAB => true,
|
||||
EmailLexer::S_CR => true,
|
||||
EmailLexer::S_LF => true
|
||||
);
|
||||
$setSpecialsWarning = true;
|
||||
|
||||
$this->lexer->moveNext();
|
||||
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) {
|
||||
$parseAgain = false;
|
||||
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$setSpecialsWarning = false;
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) {
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
|
||||
if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
if ($prev['type'] === EmailLexer::S_BACKSLASH) {
|
||||
if (!$this->checkDQUOTE(false)) {
|
||||
throw new UnclosedQuotedString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
throw new ExpectingAT();
|
||||
}
|
||||
|
||||
return $parseAgain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $closingQuote
|
||||
*/
|
||||
protected function isInvalidToken(array $token, $closingQuote)
|
||||
{
|
||||
$forbidden = array(
|
||||
EmailLexer::S_COMMA,
|
||||
EmailLexer::S_CLOSEBRACKET,
|
||||
EmailLexer::S_OPENBRACKET,
|
||||
EmailLexer::S_GREATERTHAN,
|
||||
EmailLexer::S_LOWERTHAN,
|
||||
EmailLexer::S_COLON,
|
||||
EmailLexer::S_SEMICOLON,
|
||||
EmailLexer::INVALID
|
||||
);
|
||||
|
||||
if (in_array($token['type'], $forbidden) && !$closingQuote) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\AtextAfterCFWS;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveDot;
|
||||
use Egulias\EmailValidator\Exception\CRLFAtTheEnd;
|
||||
use Egulias\EmailValidator\Exception\CRLFX2;
|
||||
use Egulias\EmailValidator\Exception\CRNoLF;
|
||||
use Egulias\EmailValidator\Exception\ExpectingQPair;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingCTEXT;
|
||||
use Egulias\EmailValidator\Exception\UnclosedComment;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\Comment;
|
||||
use Egulias\EmailValidator\Warning\QuotedPart;
|
||||
use Egulias\EmailValidator\Warning\QuotedString;
|
||||
|
||||
abstract class Parser
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $warnings = [];
|
||||
|
||||
/**
|
||||
* @var EmailLexer
|
||||
*/
|
||||
protected $lexer;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $openedParenthesis = 0;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Egulias\EmailValidator\Warning\Warning[]
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
*/
|
||||
abstract public function parse($str);
|
||||
|
||||
/** @return int */
|
||||
public function getOpenedParenthesis()
|
||||
{
|
||||
return $this->openedParenthesis;
|
||||
}
|
||||
|
||||
/**
|
||||
* validateQuotedPair
|
||||
*/
|
||||
protected function validateQuotedPair()
|
||||
{
|
||||
if (!($this->lexer->token['type'] === EmailLexer::INVALID
|
||||
|| $this->lexer->token['type'] === EmailLexer::C_DEL)) {
|
||||
throw new ExpectingQPair();
|
||||
}
|
||||
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
}
|
||||
|
||||
protected function parseComments()
|
||||
{
|
||||
$this->openedParenthesis = 1;
|
||||
$this->isUnclosedComment();
|
||||
$this->warnings[Comment::CODE] = new Comment();
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
|
||||
$this->openedParenthesis++;
|
||||
}
|
||||
$this->warnEscaping();
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUnclosedComment()
|
||||
{
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
|
||||
return true;
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new UnclosedComment();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseFWS()
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
$this->checkCRLFInFWS();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CR) {
|
||||
throw new CRNoLF();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) {
|
||||
throw new AtextAfterCFWS();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new ExpectingCTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
} else {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkConsecutiveDots()
|
||||
{
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new ConsecutiveDot();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFWS()
|
||||
{
|
||||
if ($this->escaped()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SP ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_CR ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF ||
|
||||
$this->lexer->token['type'] === EmailLexer::CRLF
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function escaped()
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH
|
||||
&&
|
||||
$this->lexer->token['type'] !== EmailLexer::GENERIC
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function warnEscaping()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasClosingQuote
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDQUOTE($hasClosingQuote)
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) {
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
if ($hasClosingQuote) {
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
$previous = $this->lexer->getPrevious();
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_DQUOTE);
|
||||
$hasClosingQuote = true;
|
||||
} catch (\Exception $e) {
|
||||
throw new UnclosedQuotedString();
|
||||
}
|
||||
$this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']);
|
||||
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
|
||||
protected function checkCRLFInFWS()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::CRLF) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||
throw new CRLFX2();
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||
throw new CRLFAtTheEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Exception\LocalOrReservedDomain;
|
||||
use Egulias\EmailValidator\Exception\DomainAcceptsNoMail;
|
||||
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
use Egulias\EmailValidator\Exception\NoDNSRecord;
|
||||
|
||||
class DNSCheckValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var InvalidEmail|null
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $mxRecords = [];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
// use the input to check DNS if we cannot extract something similar to a domain
|
||||
$host = $email;
|
||||
|
||||
// Arguable pattern to extract the domain. Not aiming to validate the domain nor the email
|
||||
if (false !== $lastAtPos = strrpos($email, '@')) {
|
||||
$host = substr($email, $lastAtPos + 1);
|
||||
}
|
||||
|
||||
// Get the domain parts
|
||||
$hostParts = explode('.', $host);
|
||||
|
||||
// Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
|
||||
// mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)
|
||||
$reservedTopLevelDnsNames = [
|
||||
// Reserved Top Level DNS Names
|
||||
'test',
|
||||
'example',
|
||||
'invalid',
|
||||
'localhost',
|
||||
|
||||
// mDNS
|
||||
'local',
|
||||
|
||||
// Private DNS Namespaces
|
||||
'intranet',
|
||||
'internal',
|
||||
'private',
|
||||
'corp',
|
||||
'home',
|
||||
'lan',
|
||||
];
|
||||
|
||||
$isLocalDomain = count($hostParts) <= 1;
|
||||
$isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true);
|
||||
|
||||
// Exclude reserved top level DNS names
|
||||
if ($isLocalDomain || $isReservedTopLevel) {
|
||||
$this->error = new LocalOrReservedDomain();
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->checkDns($host);
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDns($host)
|
||||
{
|
||||
$variant = INTL_IDNA_VARIANT_UTS46;
|
||||
|
||||
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.';
|
||||
|
||||
return $this->validateDnsRecords($host);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate the DNS records for given host.
|
||||
*
|
||||
* @param string $host A set of DNS records in the format returned by dns_get_record.
|
||||
*
|
||||
* @return bool True on success.
|
||||
*/
|
||||
private function validateDnsRecords($host)
|
||||
{
|
||||
// Get all MX, A and AAAA DNS records for host
|
||||
// Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149
|
||||
$dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA);
|
||||
|
||||
|
||||
// No MX, A or AAAA DNS records
|
||||
if (empty($dnsRecords)) {
|
||||
$this->error = new NoDNSRecord();
|
||||
return false;
|
||||
}
|
||||
|
||||
// For each DNS record
|
||||
foreach ($dnsRecords as $dnsRecord) {
|
||||
if (!$this->validateMXRecord($dnsRecord)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// No MX records (fallback to A or AAAA records)
|
||||
if (empty($this->mxRecords)) {
|
||||
$this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an MX record
|
||||
*
|
||||
* @param array $dnsRecord Given DNS record.
|
||||
*
|
||||
* @return bool True if valid.
|
||||
*/
|
||||
private function validateMxRecord($dnsRecord)
|
||||
{
|
||||
if ($dnsRecord['type'] !== 'MX') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505)
|
||||
if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') {
|
||||
$this->error = new DomainAcceptsNoMail();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->mxRecords[] = $dnsRecord;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
interface EmailValidation
|
||||
{
|
||||
/**
|
||||
* Returns true if the given email is valid.
|
||||
*
|
||||
* @param string $email The email you want to validate.
|
||||
* @param EmailLexer $emailLexer The email lexer.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer);
|
||||
|
||||
/**
|
||||
* Returns the validation error.
|
||||
*
|
||||
* @return InvalidEmail|null
|
||||
*/
|
||||
public function getError();
|
||||
|
||||
/**
|
||||
* Returns the validation warnings.
|
||||
*
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Error;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class RFCWarnings extends InvalidEmail
|
||||
{
|
||||
const CODE = 997;
|
||||
const REASON = 'Warnings were found.';
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Error;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class SpoofEmail extends InvalidEmail
|
||||
{
|
||||
const CODE = 998;
|
||||
const REASON = "The email contains mixed UTF8 chars that makes it suspicious";
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class EmptyValidationList extends \InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct($code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Empty validation list is not allowed", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class MultipleErrors extends InvalidEmail
|
||||
{
|
||||
const CODE = 999;
|
||||
const REASON = "Accumulated errors for multiple validations";
|
||||
/**
|
||||
* @var InvalidEmail[]
|
||||
*/
|
||||
private $errors = [];
|
||||
|
||||
/**
|
||||
* @param InvalidEmail[] $errors
|
||||
*/
|
||||
public function __construct(array $errors)
|
||||
{
|
||||
$this->errors = $errors;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvalidEmail[]
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Validation\Exception\EmptyValidationList;
|
||||
|
||||
class MultipleValidationWithAnd implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* If one of validations gets failure skips all succeeding validation.
|
||||
* This means MultipleErrors will only contain a single error which first found.
|
||||
*/
|
||||
const STOP_ON_ERROR = 0;
|
||||
|
||||
/**
|
||||
* All of validations will be invoked even if one of them got failure.
|
||||
* So MultipleErrors will contain all causes.
|
||||
*/
|
||||
const ALLOW_ALL_ERRORS = 1;
|
||||
|
||||
/**
|
||||
* @var EmailValidation[]
|
||||
*/
|
||||
private $validations = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var MultipleErrors|null
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @param EmailValidation[] $validations The validations.
|
||||
* @param int $mode The validation mode (one of the constants).
|
||||
*/
|
||||
public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS)
|
||||
{
|
||||
if (count($validations) == 0) {
|
||||
throw new EmptyValidationList();
|
||||
}
|
||||
|
||||
$this->validations = $validations;
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$result = true;
|
||||
$errors = [];
|
||||
foreach ($this->validations as $validation) {
|
||||
$emailLexer->reset();
|
||||
$validationResult = $validation->isValid($email, $emailLexer);
|
||||
$result = $result && $validationResult;
|
||||
$this->warnings = array_merge($this->warnings, $validation->getWarnings());
|
||||
$errors = $this->addNewError($validation->getError(), $errors);
|
||||
|
||||
if ($this->shouldStop($result)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$this->error = new MultipleErrors($errors);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError
|
||||
* @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors
|
||||
*
|
||||
* @return \Egulias\EmailValidator\Exception\InvalidEmail[]
|
||||
*/
|
||||
private function addNewError($possibleError, array $errors)
|
||||
{
|
||||
if (null !== $possibleError) {
|
||||
$errors[] = $possibleError;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $result
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldStop($result)
|
||||
{
|
||||
return !$result && $this->mode === self::STOP_ON_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validation errors.
|
||||
*
|
||||
* @return MultipleErrors|null
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\Error\RFCWarnings;
|
||||
|
||||
class NoRFCWarningsValidation extends RFCValidation
|
||||
{
|
||||
/**
|
||||
* @var InvalidEmail|null
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
if (!parent::isValid($email, $emailLexer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->getWarnings())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->error = new RFCWarnings();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error ?: parent::getError();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class RFCValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var EmailParser|null
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var InvalidEmail|null
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$this->parser = new EmailParser($emailLexer);
|
||||
try {
|
||||
$this->parser->parse((string)$email);
|
||||
} catch (InvalidEmail $invalid) {
|
||||
$this->error = $invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->warnings = $this->parser->getWarnings();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\Error\SpoofEmail;
|
||||
use \Spoofchecker;
|
||||
|
||||
class SpoofCheckValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var InvalidEmail|null
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!extension_loaded('intl')) {
|
||||
throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidArgument
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$checker = new Spoofchecker();
|
||||
$checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
|
||||
|
||||
if ($checker->isSuspicious($email)) {
|
||||
$this->error = new SpoofEmail();
|
||||
}
|
||||
|
||||
return $this->error === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvalidEmail|null
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class AddressLiteral extends Warning
|
||||
{
|
||||
const CODE = 12;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Address literal in domain part';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSNearAt extends Warning
|
||||
{
|
||||
const CODE = 49;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Deprecated folding white space near @";
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSWithFWS extends Warning
|
||||
{
|
||||
const CODE = 18;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Folding whites space followed by folding white space';
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class Comment extends Warning
|
||||
{
|
||||
const CODE = 17;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Comments found in this email";
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DeprecatedComment extends Warning
|
||||
{
|
||||
const CODE = 37;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated comments';
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainLiteral extends Warning
|
||||
{
|
||||
const CODE = 70;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain Literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainTooLong extends Warning
|
||||
{
|
||||
const CODE = 255;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain is too long, exceeds 255 chars';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
|
||||
class EmailTooLong extends Warning
|
||||
{
|
||||
const CODE = 66;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Email is too long, exceeds ' . EmailParser::EMAIL_MAX_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6BadChar extends Warning
|
||||
{
|
||||
const CODE = 74;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Bad char in IPV6 domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonEnd extends Warning
|
||||
{
|
||||
const CODE = 77;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the end of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonStart extends Warning
|
||||
{
|
||||
const CODE = 76;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the start of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6Deprecated extends Warning
|
||||
{
|
||||
const CODE = 13;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated form of IPV6';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6DoubleColon extends Warning
|
||||
{
|
||||
const CODE = 73;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Double colon found after IPV6 tag';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6GroupCount extends Warning
|
||||
{
|
||||
const CODE = 72;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Group count is not IPV6 valid';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6MaxGroups extends Warning
|
||||
{
|
||||
const CODE = 75;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Reached the maximum number of IPV6 groups allowed';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LabelTooLong extends Warning
|
||||
{
|
||||
const CODE = 63;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Label too long';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LocalTooLong extends Warning
|
||||
{
|
||||
const CODE = 64;
|
||||
const LOCAL_PART_LENGTH = 64;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Local part is too long, exceeds 64 chars (octets)';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class NoDNSMXRecord extends Warning
|
||||
{
|
||||
const CODE = 6;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'No MX DSN record was found for this email';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class ObsoleteDTEXT extends Warning
|
||||
{
|
||||
const CODE = 71;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->rfcNumber = 5322;
|
||||
$this->message = 'Obsolete DTEXT in domain literal';
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedPart extends Warning
|
||||
{
|
||||
const CODE = 36;
|
||||
|
||||
/**
|
||||
* @param scalar $prevToken
|
||||
* @param scalar $postToken
|
||||
*/
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Deprecated Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedString extends Warning
|
||||
{
|
||||
const CODE = 11;
|
||||
|
||||
/**
|
||||
* @param scalar $prevToken
|
||||
* @param scalar $postToken
|
||||
*/
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class TLD extends Warning
|
||||
{
|
||||
const CODE = 9;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "RFC5321, TLD";
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
abstract class Warning
|
||||
{
|
||||
const CODE = 0;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $message = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $rfcNumber = 0;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function code()
|
||||
{
|
||||
return static::CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function RFCNumber()
|
||||
{
|
||||
return $this->rfcNumber;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
2
lib/necolas/normalize.css/.gitattributes
vendored
2
lib/necolas/normalize.css/.gitattributes
vendored
@@ -1,2 +0,0 @@
|
||||
normalize.css linguist-vendored=false
|
||||
test.html linguist-vendored
|
||||
1
lib/necolas/normalize.css/.gitignore
vendored
1
lib/necolas/normalize.css/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
@@ -1,3 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
@@ -1,175 +0,0 @@
|
||||
# Changes to normalize.css
|
||||
|
||||
### 8.0.1 (November 4, 2018)
|
||||
|
||||
* Fix regression in IE rendering of `main` element.
|
||||
|
||||
### 8.0.0 (February 2, 2018)
|
||||
|
||||
* Remove support for older browsers Android 4, lte IE 9, lte Safari 7.
|
||||
* Don't remove search input cancel button in Chrome/Safari.
|
||||
* Form inputs inherit `font-family`.
|
||||
* Fix text decoration in Safari 8+.
|
||||
|
||||
### 7.0.0 (May 2, 2017)
|
||||
|
||||
* Revert changes in `body` and form elements styles introduced by v6
|
||||
|
||||
### 6.0.0 (March 26, 2017)
|
||||
|
||||
* Remove all opinionated rules
|
||||
* Correct document heading comment
|
||||
* Update `abbr[title]` support
|
||||
|
||||
### 5.0.0 (October 3, 2016)
|
||||
|
||||
* Add normalized sections not already present from
|
||||
https://html.spec.whatwg.org/multipage/.
|
||||
* Move unsorted rules into their respective sections.
|
||||
* Update the `summary` style in all browsers.
|
||||
* Remove `::placeholder` styles due to a bug in Edge.
|
||||
* More explicitly define font resets on form controls.
|
||||
* Remove the `optgroup` normalization needed by the previous font reset.
|
||||
* Update text-size-adjust documentation
for IE on Windows Phone
|
||||
* Update OS X reference to macOS
|
||||
* Update the semver strategy.
|
||||
|
||||
### 4.2.0 (June 30, 2016)
|
||||
|
||||
* Correct the `line-height` in all browsers.
|
||||
* Restore `optgroup` font inheritance.
|
||||
* Update normalize.css heading.
|
||||
|
||||
### 4.1.1 (April 12, 2016)
|
||||
|
||||
* Update normalize.css heading.
|
||||
|
||||
### 4.1.0 (April 11, 2016)
|
||||
|
||||
* Normalize placeholders in Chrome, Edge, and Safari.
|
||||
* Normalize `text-decoration-skip` property in Safari.
|
||||
* Normalize file select buttons.
|
||||
* Normalize search input outlines in Safari.
|
||||
* Limit Firefox focus normalizations to buttons.
|
||||
* Restore `main` to package.json.
|
||||
* Restore proper overflow to certain `select` elements.
|
||||
* Remove opinionated cursor styles on buttons.
|
||||
* Update stylelint configuration.
|
||||
* Update tests.
|
||||
|
||||
### 4.0.0 (March 19, 2016)
|
||||
|
||||
* Add the correct font weight for `b` and `strong` in Chrome, Edge, and Safari.
|
||||
* Correct inconsistent `overflow` for `hr` in Edge and IE.
|
||||
* Correct inconsistent `box-sizing` for `hr` in Firefox.
|
||||
* Correct inconsistent `text-decoration` and `border-bottom` for `abbr[title]`
|
||||
in Chrome, Edge, Firefox IE, Opera, and Safari.
|
||||
* Correct inheritance and scaling of `font-size` for preformatted text.
|
||||
* Correct `legend` text wrapping not present in Edge and IE.
|
||||
* Remove unnecessary normalization of `line-height` for `input`.
|
||||
* Remove unnecessary normalization of `color` for form controls.
|
||||
* Remove unnecessary `box-sizing` for `input[type="search"]` in Chrome, Edge,
|
||||
Firefox, IE, and Safari.
|
||||
* Remove opinionated table resets.
|
||||
* Remove opinionated `pre` overflow.
|
||||
* Remove selector weight from some input selectors.
|
||||
* Update normalization of `border-style` for `img`.
|
||||
* Update normalization of `color` inheritance for `legend`.
|
||||
* Update normalization of `background-color` for `mark`.
|
||||
* Update normalization of `outline` for `:-moz-focusring` removed by a previous
|
||||
normalization in Firefox.
|
||||
* Update opinionated style of `outline-width` for `a:active` and `a:hover`.
|
||||
* Update comments to identify opinionated styles.
|
||||
* Update comments to specify browser/versions affected by all changes.
|
||||
* Update comments to use one voice.
|
||||
|
||||
---
|
||||
|
||||
### 3.0.3 (March 30, 2015)
|
||||
|
||||
* Remove unnecessary vendor prefixes.
|
||||
* Add `main` property.
|
||||
|
||||
### 3.0.2 (October 4, 2014)
|
||||
|
||||
* Only alter `background-color` of links in IE 10.
|
||||
* Add `menu` element to HTML5 display definitions.
|
||||
|
||||
### 3.0.1 (March 27, 2014)
|
||||
|
||||
* Add package.json for npm support.
|
||||
|
||||
### 3.0.0 (January 28, 2014)
|
||||
|
||||
### 3.0.0-rc.1 (January 26, 2014)
|
||||
|
||||
* Explicit tests for each normalization.
|
||||
* Fix i18n for `q` element.
|
||||
* Fix `pre` text formatting and overflow.
|
||||
* Fix vertical alignment of `progress`.
|
||||
* Address `button` overflow in IE 8/9/10.
|
||||
* Revert `textarea` alignment modification.
|
||||
* Fix number input button cursor in Chrome on OS X.
|
||||
* Remove `a:focus` outline normalization.
|
||||
* Fix `figure` margin normalization.
|
||||
* Normalize `optgroup`.
|
||||
* Remove default table cell padding.
|
||||
* Set correct display for `progress` in IE 8/9.
|
||||
* Fix `font` and `color` inheritance for forms.
|
||||
|
||||
---
|
||||
|
||||
### 2.1.3 (August 26, 2013)
|
||||
|
||||
* Fix component.json.
|
||||
* Remove the gray background color from active links in IE 10.
|
||||
|
||||
### 2.1.2 (May 11, 2013)
|
||||
|
||||
* Revert root `color` and `background` normalizations.
|
||||
|
||||
### 2.1.1 (April 8, 2013)
|
||||
|
||||
* Normalize root `color` and `background` to counter the effects of system
|
||||
color schemes.
|
||||
|
||||
### 2.1.0 (January 21, 2013)
|
||||
|
||||
* Normalize `text-transform` for `button` and `select`.
|
||||
* Normalize `h1` margin when within HTML5 sectioning elements.
|
||||
* Normalize `hr` element.
|
||||
* Remove unnecessary `pre` styles.
|
||||
* Add `main` element to HTML5 display definitions.
|
||||
* Fix cursor style for disabled button `input`.
|
||||
|
||||
### 2.0.1 (August 20, 2012)
|
||||
|
||||
* Remove stray IE 6/7 `inline-block` hack from HTML5 display settings.
|
||||
|
||||
### 2.0.0 (August 19, 2012)
|
||||
|
||||
* Remove legacy browser form normalizations.
|
||||
* Remove all list normalizations.
|
||||
* Add `quotes` normalizations.
|
||||
* Remove all heading normalizations except `h1` font size.
|
||||
* Form elements automatically inherit `font-family` from ancestor.
|
||||
* Drop support for IE 6/7, Firefox < 4, and Safari < 5.
|
||||
|
||||
---
|
||||
|
||||
### 1.0.1 (August 19, 2012)
|
||||
|
||||
* Adjust `small` font size normalization.
|
||||
|
||||
### 1.0.0 (August 14, 2012)
|
||||
|
||||
(Only the notable changes since public release)
|
||||
|
||||
* Add MIT License.
|
||||
* Hide `audio` elements without controls in iOS 5.
|
||||
* Normalize heading margins and font size.
|
||||
* Move font-family normalization from `body` to `html`.
|
||||
* Remove scrollbar normalization.
|
||||
* Remove excess padding from checkbox and radio inputs in IE 7.
|
||||
* Add IE9 correction for SVG overflow.
|
||||
* Add fix for legend not inheriting color in IE 6/7/8/9.
|
||||
@@ -1,197 +0,0 @@
|
||||
# Contributing to normalize.css
|
||||
|
||||
Please take a moment to review this document in order to make the contribution
|
||||
process easy and effective for everyone involved.
|
||||
|
||||
Following these guidelines helps to communicate that you respect the time of
|
||||
the developers managing and developing this open source project. In return,
|
||||
they should reciprocate that respect in addressing your issue or assessing
|
||||
patches and features.
|
||||
|
||||
|
||||
## Using the issue tracker
|
||||
|
||||
The issue tracker is the preferred channel for [bug reports](#bugs),
|
||||
[features requests](#features) and [submitting pull
|
||||
requests](#pull-requests), but please respect the following restrictions:
|
||||
|
||||
* Please **do not** use the issue tracker for personal support requests.
|
||||
|
||||
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
||||
respect the opinions of others.
|
||||
|
||||
|
||||
## Bug reports
|
||||
|
||||
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
||||
Good bug reports are extremely helpful - thank you!
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
1. **Use the GitHub issue search** – check if the issue has already been
|
||||
reported.
|
||||
|
||||
2. **Check if the issue has been fixed** – try to reproduce it using the
|
||||
latest `master` branch in the repository.
|
||||
|
||||
3. **Isolate the problem** – create a live example (e.g., on
|
||||
[Codepen](http://codepen.io)) of a [reduced test
|
||||
case](http://css-tricks.com/6263-reduced-test-cases/).
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more
|
||||
information. Please try to be as detailed as possible in your report. What is
|
||||
your environment? What steps will reproduce the issue? What browser(s) and OS
|
||||
experience the problem? What would you expect to be the outcome? All these
|
||||
details will help people to fix any potential bugs.
|
||||
|
||||
Example:
|
||||
|
||||
> Short and descriptive example bug report title
|
||||
>
|
||||
> A summary of the issue and the browser/OS environment in which it occurs. If
|
||||
> suitable, include the steps required to reproduce the bug.
|
||||
>
|
||||
> 1. This is the first step
|
||||
> 2. This is the second step
|
||||
> 3. Further steps, etc.
|
||||
>
|
||||
> `<url>` - a link to the reduced test case
|
||||
>
|
||||
> Any other information you want to share that is relevant to the issue being
|
||||
> reported. This might include the lines of code that you have identified as
|
||||
> causing the bug, and potential solutions (and your opinions on their
|
||||
> merits).
|
||||
|
||||
|
||||
## Feature requests
|
||||
|
||||
Feature requests are welcome. But take a moment to find out whether your idea
|
||||
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||
case to convince the project's developers of the merits of this feature. Please
|
||||
provide as much detail and context as possible.
|
||||
|
||||
|
||||
## Pull requests
|
||||
|
||||
Good pull requests - patches, improvements, new features - are a fantastic
|
||||
help. They should remain focused in scope and avoid containing unrelated
|
||||
commits.
|
||||
|
||||
**Please ask first** before embarking on any significant work, otherwise you
|
||||
risk spending a lot of time working on something that the project's developers
|
||||
might not want to merge into the project.
|
||||
|
||||
Please adhere to the coding conventions used throughout a project (whitespace,
|
||||
accurate comments, etc.) and any other requirements (such as test coverage).
|
||||
|
||||
Follow this process if you'd like your work considered for inclusion in the
|
||||
project:
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your
|
||||
fork, and configure the remotes:
|
||||
|
||||
```bash
|
||||
# Clone your fork of the repo into the current directory
|
||||
git clone https://github.com/<your-username>/normalize.css
|
||||
# Navigate to the newly cloned directory
|
||||
cd normalize.css
|
||||
# Assign the original repo to a remote called "upstream"
|
||||
git remote add upstream https://github.com/necolas/normalize.css
|
||||
```
|
||||
|
||||
2. If you cloned a while ago, get the latest changes from upstream:
|
||||
|
||||
```bash
|
||||
git checkout master
|
||||
git pull upstream master
|
||||
```
|
||||
|
||||
3. Never work directly on `master`. Create a new topic branch (off the latest
|
||||
version of `master`) to contain your feature, change, or fix:
|
||||
|
||||
```bash
|
||||
git checkout -b <topic-branch-name>
|
||||
```
|
||||
|
||||
4. Commit your changes in logical chunks. Please adhere to these [git commit
|
||||
message conventions](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||
or your code is unlikely be merged into the main project. Use Git's
|
||||
[interactive rebase](https://help.github.com/articles/interactive-rebase)
|
||||
feature to tidy up your commits before making them public.
|
||||
|
||||
Be sure to add a test to the `test.html` file if appropriate, and test
|
||||
your change in all supported browsers.
|
||||
|
||||
5. Locally rebase the upstream development branch into your topic branch:
|
||||
|
||||
```bash
|
||||
git pull --rebase upstream master
|
||||
```
|
||||
|
||||
6. Push your topic branch up to your fork:
|
||||
|
||||
```bash
|
||||
git push origin <topic-branch-name>
|
||||
```
|
||||
|
||||
10. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
|
||||
with a clear title and description.
|
||||
|
||||
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
|
||||
license your work under the same license as that used by the project.
|
||||
|
||||
### CSS Conventions
|
||||
|
||||
Keep the CSS file as readable as possible by following these guidelines:
|
||||
|
||||
- Comments are short and to the point.
|
||||
- Comments without a number reference the entire rule.
|
||||
- Comments describe the selector when the selector does not make the
|
||||
normalization obvious.
|
||||
- Comments begin with “Correct the...” when they deal with less obvious side
|
||||
effects.
|
||||
- Rules are sorted by cascade, specificity, and then alphabetic order.
|
||||
- Selectors are sorted by specificity and then alphabetic order.
|
||||
- `in browser` applies to all versions.
|
||||
- `in browser v-` applies to all versions up to and including the version.
|
||||
- `in browser v+` applies to all versions after and including the version.
|
||||
- `in browser v-v` applies to all versions including and between the versions.
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
If you have commit access, please follow this process for merging patches and
|
||||
cutting new releases.
|
||||
|
||||
### Accepting patches
|
||||
|
||||
1. Check that a patch is within the scope and philosophy of the project.
|
||||
2. Check that a patch has any necessary tests and a proper, descriptive commit
|
||||
message.
|
||||
3. Test the patch locally.
|
||||
4. Do not use GitHub's merge button. Apply the patch to `master` locally
|
||||
(either via `git am` or by checking the whole branch out). Amend minor
|
||||
problems with the author's original commit if necessary. Then push to GitHub.
|
||||
|
||||
### Releasing a new version
|
||||
|
||||
1. Include all new functional changes in the CHANGELOG.
|
||||
2. Use a dedicated commit to increment the version. The version needs to be
|
||||
added to the CHANGELOG (inc. date), the `package.json`, and `normalize.css`
|
||||
files.
|
||||
3. The commit message must be of `v0.0.0` format.
|
||||
4. Create an annotated tag for the version: `git tag -m "v0.0.0" 0.0.0`.
|
||||
5. Push the changes and tags to GitHub: `git push --tags origin master`
|
||||
6. Checkout the `gh-pages` branch and follow the instructions in the README.
|
||||
|
||||
### Semver strategy
|
||||
|
||||
[Semver](http://semver.org/) is a widely accepted method for deciding how
|
||||
version numbers are incremented in a project. Versions are written as
|
||||
MAJOR.MINOR.PATCH.
|
||||
|
||||
Any change to CSS rules whatsoever is considered backwards-breaking and will
|
||||
result in a new **major** release. No changes to CSS rules can add
|
||||
functionality in a backwards-compatible manner, therefore no changes are
|
||||
considered **minor**. Others changes with no impact on rendering are considered
|
||||
backwards-compatible and will result in a new **patch** release.
|
||||
@@ -1,21 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright © Nicolas Gallagher and Jonathan Neal
|
||||
|
||||
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.
|
||||
@@ -1,102 +0,0 @@
|
||||
# normalize.css
|
||||
|
||||
<a href="https://github.com/necolas/normalize.css"><img
|
||||
src="https://necolas.github.io/normalize.css/logo.svg" alt="Normalize Logo"
|
||||
width="80" height="80" align="right"></a>
|
||||
|
||||
> A modern alternative to CSS resets
|
||||
|
||||
[![npm][npm-image]][npm-url] [![license][license-image]][license-url]
|
||||
[![changelog][changelog-image]][changelog-url]
|
||||
[![gitter][gitter-image]][gitter-url]
|
||||
|
||||
|
||||
**NPM**
|
||||
|
||||
```sh
|
||||
npm install --save normalize.css
|
||||
```
|
||||
|
||||
**CDN**
|
||||
|
||||
See https://yarnpkg.com/en/package/normalize.css
|
||||
|
||||
**Download**
|
||||
|
||||
See https://necolas.github.io/normalize.css/latest/normalize.css
|
||||
|
||||
|
||||
## What does it do?
|
||||
|
||||
* Preserves useful defaults, unlike many CSS resets.
|
||||
* Normalizes styles for a wide range of elements.
|
||||
* Corrects bugs and common browser inconsistencies.
|
||||
* Improves usability with subtle modifications.
|
||||
* Explains what code does using detailed comments.
|
||||
|
||||
|
||||
## Browser support
|
||||
|
||||
* Chrome
|
||||
* Edge
|
||||
* Firefox ESR+
|
||||
* Internet Explorer 10+
|
||||
* Safari 8+
|
||||
* Opera
|
||||
|
||||
|
||||
## Extended details and known issues
|
||||
|
||||
Additional detail and explanation of the esoteric parts of normalize.css.
|
||||
|
||||
#### `pre, code, kbd, samp`
|
||||
|
||||
The `font-family: monospace, monospace` hack fixes the inheritance and scaling
|
||||
of font-size for preformatted text. The duplication of `monospace` is
|
||||
intentional. [Source](https://en.wikipedia.org/wiki/User:Davidgothberg/Test59).
|
||||
|
||||
#### `sub, sup`
|
||||
|
||||
Normally, using `sub` or `sup` affects the line-box height of text in all
|
||||
browsers. [Source](https://gist.github.com/413930).
|
||||
|
||||
#### `select`
|
||||
|
||||
By default, Chrome on OS X and Safari on OS X allow very limited styling of
|
||||
`select`, unless a border property is set. The default font weight on `optgroup`
|
||||
elements cannot safely be changed in Chrome on OSX and Safari on OS X.
|
||||
|
||||
#### `[type="checkbox"]`
|
||||
|
||||
It is recommended that you do not style checkbox and radio inputs as Firefox's
|
||||
implementation does not respect box-sizing, padding, or width.
|
||||
|
||||
#### `[type="number"]`
|
||||
|
||||
Certain font size values applied to number inputs cause the cursor style of the
|
||||
decrement button to change from `default` to `text`.
|
||||
|
||||
#### `[type="search"]`
|
||||
|
||||
The search input is not fully stylable by default. In Chrome and Safari on
|
||||
OSX/iOS you can't control `font`, `padding`, `border`, or `background`. In
|
||||
Chrome and Safari on Windows you can't control `border` properly. It will apply
|
||||
`border-width` but will only show a border color (which cannot be controlled)
|
||||
for the outer 1px of that border. Applying `-webkit-appearance: textfield`
|
||||
addresses these issues without removing the benefits of search inputs (e.g.
|
||||
showing past searches).
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read the [contribution guidelines](CONTRIBUTING.md) in order to make the
|
||||
contribution process easy and effective for everyone involved.
|
||||
|
||||
|
||||
[changelog-image]: https://img.shields.io/badge/changelog-md-blue.svg?style=flat-square
|
||||
[changelog-url]: CHANGELOG.md
|
||||
[license-image]: https://img.shields.io/npm/l/normalize.css.svg?style=flat-square
|
||||
[license-url]: LICENSE.md
|
||||
[npm-image]: https://img.shields.io/npm/v/normalize.css.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/normalize.css
|
||||
[gitter-image]: https://img.shields.io/badge/chat-gitter-blue.svg?style=flat-square
|
||||
[gitter-url]: https://gitter.im/necolas/normalize.css
|
||||
349
lib/necolas/normalize.css/normalize.css
vendored
349
lib/necolas/normalize.css/normalize.css
vendored
@@ -1,349 +0,0 @@
|
||||
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
||||
|
||||
/* Document
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Correct the line height in all browsers.
|
||||
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
||||
*/
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the margin in all browsers.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the `main` element consistently in IE.
|
||||
*/
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the font size and margin on `h1` elements within `section` and
|
||||
* `article` contexts in Chrome, Firefox, and Safari.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in Firefox.
|
||||
* 2. Show the overflow in Edge and IE.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box; /* 1 */
|
||||
height: 0; /* 1 */
|
||||
overflow: visible; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the gray background on active links in IE 10.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the bottom border in Chrome 57-
|
||||
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font weight in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` elements from affecting the line height in
|
||||
* all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the border on images inside links in IE 10.
|
||||
*/
|
||||
|
||||
img {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
/* Forms
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Change the font styles in all browsers.
|
||||
* 2. Remove the margin in Firefox and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit; /* 1 */
|
||||
font-size: 100%; /* 1 */
|
||||
line-height: 1.15; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the overflow in IE.
|
||||
* 1. Show the overflow in Edge.
|
||||
*/
|
||||
|
||||
button,
|
||||
input { /* 1 */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
||||
* 1. Remove the inheritance of text transform in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select { /* 1 */
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the inability to style clickable types in iOS and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
[type="button"],
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner border and padding in Firefox.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the focus styles unset by the previous rule.
|
||||
*/
|
||||
|
||||
button:-moz-focusring,
|
||||
[type="button"]:-moz-focusring,
|
||||
[type="reset"]:-moz-focusring,
|
||||
[type="submit"]:-moz-focusring {
|
||||
outline: 1px dotted ButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the padding in Firefox.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
padding: 0.35em 0.75em 0.625em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the text wrapping in Edge and IE.
|
||||
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
||||
* 3. Remove the padding so developers are not caught out when they zero out
|
||||
* `fieldset` elements in all browsers.
|
||||
*/
|
||||
|
||||
legend {
|
||||
box-sizing: border-box; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
display: table; /* 1 */
|
||||
max-width: 100%; /* 1 */
|
||||
padding: 0; /* 3 */
|
||||
white-space: normal; /* 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the default vertical scrollbar in IE 10+.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in IE 10.
|
||||
* 2. Remove the padding in IE 10.
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the cursor style of increment and decrement buttons in Chrome.
|
||||
*/
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the odd appearance in Chrome and Safari.
|
||||
* 2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner padding in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inability to style clickable types in iOS and Safari.
|
||||
* 2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/* Interactive
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Add the correct display in Edge, IE 10+, and Firefox.
|
||||
*/
|
||||
|
||||
details {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the correct display in all browsers.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Misc
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10+.
|
||||
*/
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
5
lib/necolas/normalize.css/package-lock.json
generated
5
lib/necolas/normalize.css/package-lock.json
generated
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "normalize.css",
|
||||
"version": "8.0.1",
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "normalize.css",
|
||||
"version": "8.0.1",
|
||||
"description": "A modern alternative to CSS resets",
|
||||
"main": "normalize.css",
|
||||
"style": "normalize.css",
|
||||
"files": [
|
||||
"LICENSE.md",
|
||||
"normalize.css"
|
||||
],
|
||||
"repository": "necolas/normalize.css",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/necolas/normalize.css/issues",
|
||||
"homepage": "https://necolas.github.io/normalize.css"
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Normalize CSS: UI tests</title>
|
||||
<script src="https://rawgit.com/aFarkas/html5shiv/gh-pages/dist/html5shiv.min.js"></script>
|
||||
<link rel="stylesheet" href="normalize.css">
|
||||
<style>
|
||||
/*! suit-test v0.1.0 | MIT License | github.com/suitcss */
|
||||
|
||||
.Test {
|
||||
background: #fff;
|
||||
counter-reset: test-describe;
|
||||
}
|
||||
|
||||
.Test-describe:before {
|
||||
content: counter(test-describe);
|
||||
counter-increment: test-describe;
|
||||
}
|
||||
|
||||
.Test-describe {
|
||||
counter-reset: test-it;
|
||||
}
|
||||
|
||||
.Test-it:before {
|
||||
content: counter(test-describe) "." counter(test-it);
|
||||
counter-increment: test-it;
|
||||
}
|
||||
|
||||
.Test-title {
|
||||
font-size: 2em;
|
||||
font-family: sans-serif;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
background: #eee;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.Test-describe,
|
||||
.Test-it {
|
||||
background: #eee;
|
||||
border-left: 5px solid #666;
|
||||
color: #666;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
margin: 20px 0;
|
||||
padding: 0.75em 20px;
|
||||
}
|
||||
|
||||
.Test-describe {
|
||||
font-size: 1.5em;
|
||||
margin: 60px 0 20px;
|
||||
}
|
||||
|
||||
.Test-describe:before,
|
||||
.Test-it:before {
|
||||
color: #999;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
min-width: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Custom helpers */
|
||||
|
||||
/**
|
||||
* Test whether the body's margin has been removed
|
||||
*/
|
||||
|
||||
body {
|
||||
background: red;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight the bounds of direct children of a test block
|
||||
*/
|
||||
|
||||
.Test-run--highlightEl > * {
|
||||
outline: 1px solid #ADD8E6;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="Test">
|
||||
.
|
||||
|
||||
<h1 class="Test-title"><a href="https://github.com/necolas/normalize.css">Normalize.css</a>: UI tests</h1>
|
||||
|
||||
<h2 class="Test-describe"><code>html</code></h2>
|
||||
<h3 class="Test-it">should have a line height of 1.15</h3>
|
||||
<div class="Test-run">
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>body</code></h2>
|
||||
<h3 class="Test-it">should have no margin (opinionated)</h3>
|
||||
<div class="Test-run">
|
||||
(there should be no red background visible on this page)
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe">
|
||||
<code>article</code>, <code>aside</code>, <code>details</code>,
|
||||
<code>figure</code>, <code>figcaption</code>, <code>footer</code>,
|
||||
<code>header</code>, <code>main</code>,
|
||||
<code>menu</code>, <code>nav</code>, <code>section</code>,
|
||||
<code>summary</code>
|
||||
</h2>
|
||||
<h3 class="Test-it">should render as block</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<article>article</article>
|
||||
<aside>aside</aside>
|
||||
<details>
|
||||
<summary>summary</summary>
|
||||
details
|
||||
</details>
|
||||
<figure>
|
||||
figure
|
||||
<figcaption>figcaption</figcaption>
|
||||
</figure>
|
||||
<footer>footer</footer>
|
||||
<header>header</header>
|
||||
<main>main</main>
|
||||
<menu><li>menu</li></menu>
|
||||
<nav>nav</nav>
|
||||
<section>section</section>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>audio</code>, <code>canvas</code>, <code>progress</code>, <code>video</code></h2>
|
||||
<h3 class="Test-it">should render as inline-block and baseline-aligned</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<audio controls>audio</audio>
|
||||
<canvas>canvas</canvas>
|
||||
<progress>progress</progress>
|
||||
<video controls>video</video>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>audio:not([controls])</code>, <code>template</code>, <code>[hidden]</code></h2>
|
||||
<h3 class="Test-it">should not display</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<audio>audio</audio>
|
||||
<template>
|
||||
<h1>{{title}}</h1>
|
||||
<content></content>
|
||||
</template>
|
||||
<p hidden>This should be hidden</p>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>a</code></h2>
|
||||
<h3 class="Test-it">should have a transparent background when active</h3>
|
||||
<div class="Test-run">
|
||||
<a href="#non">dummy anchor</a>
|
||||
</div>
|
||||
<h3 class="Test-it">should not skip underlines</h3>
|
||||
<div class="Test-run">
|
||||
<a href="#non">quip and jig</a>
|
||||
</div>
|
||||
<h3 class="Test-it">should not have a focus outline when both focused and hovered (opinionated)</h3>
|
||||
<div class="Test-run">
|
||||
<a href="#non">dummy anchor</a>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>abbr[title]</code></h2>
|
||||
<h3 class="Test-it">should have a dotted underline with a solid underline as a fallback</h3>
|
||||
<div class="Test-run">
|
||||
<abbr title="abbreviation">abbr</abbr>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>b</code>, <code>strong</code></h2>
|
||||
<h3 class="Test-it">should have bolder font-weight</h3>
|
||||
<div class="Test-run">
|
||||
<b>b</b>
|
||||
<strong>strong</strong>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>dfn</code></h2>
|
||||
<h3 class="Test-it">should have italic font-style</h3>
|
||||
<div class="Test-run">
|
||||
<dfn>dfn</dfn>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>h1</code></h2>
|
||||
<h3 class="Test-it">should not change size within an <code>article</code></h3>
|
||||
<div class="Test-run">
|
||||
<h1>Heading (control)</h1>
|
||||
<article>
|
||||
<h1>Heading (in article)</h1>
|
||||
</article>
|
||||
</div>
|
||||
<h3 class="Test-it">should not change size within a <code>section</code></h3>
|
||||
<div class="Test-run">
|
||||
<h1>Heading (control)</h1>
|
||||
<section>
|
||||
<h1>Heading (in section)</h1>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>mark</code></h2>
|
||||
<h3 class="Test-it">should have a yellow background</h3>
|
||||
<div class="Test-run">
|
||||
<mark>mark</mark>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>small</code></h2>
|
||||
<h3 class="Test-it">should render equally small in all browsers</h3>
|
||||
<div class="Test-run">
|
||||
control. <small>small.</small>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>sub</code> and <code>sup</code></h2>
|
||||
<h3 class="Test-it">should not affect a line's visual line-height</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<p>control.</p>
|
||||
<p>control. <sub>sub.</sub></p>
|
||||
<p>control. <sup>sup.</sup></p>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>img</code></h2>
|
||||
<h3 class="Test-it">should not have a border when wrapped in an anchor</h3>
|
||||
<div class="Test-run">
|
||||
<a href="#non">
|
||||
<!-- scaled-up 1px image -->
|
||||
<img style="background-color:#ADD8E6" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width="100" height="100">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>svg</code></h2>
|
||||
<h3 class="Test-it">should not overflow</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<svg width="100px" height="100px">
|
||||
<circle cx="100" cy="100" r="100" fill="#ADD8E6" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>code</code>, <code>kbd</code>, <code>pre</code>, <code>samp</code></h2>
|
||||
<h3 class="Test-it">should render text at the same absolute size as normal text</h3>
|
||||
<div class="Test-run">
|
||||
<span>span: abcdefghijklmnopqrstuvwxyz.</span><br>
|
||||
<code>code: abcdefghijklmnopqrstuvwxyz.</code><br>
|
||||
<kbd>kbd: abcdefghijklmnopqrstuvwxyz.</kbd><br>
|
||||
<samp>samp: abcdefghijklmnopqrstuvwxyz.</samp>
|
||||
<pre>pre: abcdefghijklmnopqrstuvwxyz.</pre>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>figure</code></h2>
|
||||
<h3 class="Test-it">should have margins</h3>
|
||||
<div class="Test-run" style="outline:1px solid #ADD8E6; overflow:hidden;">
|
||||
<figure>
|
||||
<img style="background-color:#ADD8E6" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width="400" height="200">
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>hr</code></h2>
|
||||
<h3 class="Test-it">should have a <code>content-box</code> box model</h3>
|
||||
<div class="Test-run" style="">
|
||||
<hr style="height:2px; border:solid #ADD8E6; border-width:2px 0;">
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>button</code>, <code>input</code>, <code>optgroup</code>, <code>select</code>, <code>textarea</code></h2>
|
||||
<h3 class="Test-it">should inherit <code>font-size</code> from ancestor</h3>
|
||||
<div class="Test-run" style="font-size: 20px;">
|
||||
<button>button</button><br>
|
||||
<input value="input"><br>
|
||||
<select style="border:1px solid #999;">
|
||||
<optgroup label="optgroup">
|
||||
<option>option</option>
|
||||
</optgroup>
|
||||
<option>option</option>
|
||||
</select><br>
|
||||
<textarea>textarea</textarea>
|
||||
</div>
|
||||
<h3 class="Test-it">should not have margins</h3>
|
||||
<div class="Test-run" id="form-collection-margins">
|
||||
<style>
|
||||
#form-collection-margins {
|
||||
outline: 1px solid #ADD8E6;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#form-collection-margins button,
|
||||
#form-collection-margins input,
|
||||
#form-collection-margins select,
|
||||
#form-collection-margins textarea {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<button>button</button>
|
||||
<input value="input">
|
||||
<select style="border:1px solid #999;">
|
||||
<optgroup label="optgroup">
|
||||
<option>option</option>
|
||||
</optgroup>
|
||||
<option>option</option>
|
||||
</select>
|
||||
<textarea>textarea</textarea>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>button</code></h2>
|
||||
<h3 class="Test-it">should have visible overflow</h3>
|
||||
<div class="Test-run" id="button-overflow">
|
||||
<style>
|
||||
#button-overflow button:after {
|
||||
content: "";
|
||||
background: #ADD8E6;
|
||||
display: inline-block;
|
||||
height: 10px;
|
||||
position:relative;
|
||||
right: -20px;
|
||||
width: 10px;
|
||||
}
|
||||
</style>
|
||||
<button>abcdefghijklmnopqrstuvwxyz</button>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>button</code>, <code>select</code></h2>
|
||||
<h3 class="Test-it">should not inherit <code>text-transform</code></h3>
|
||||
<div class="Test-run" style="text-transform:uppercase">
|
||||
<button>button</button>
|
||||
<select><option>option</option></select>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>button</code> and button-style <code>input</code></h2>
|
||||
<h3 class="Test-it">should be styleable</h3>
|
||||
<div class="Test-run" id="button-like-style">
|
||||
<style>
|
||||
#button-like-style button,
|
||||
#button-like-style input {
|
||||
background: #ADD8E6;
|
||||
border: 2px solid black;
|
||||
border-radius: 2px;
|
||||
padding: 5px;
|
||||
}
|
||||
</style>
|
||||
<p><button>button</button></p>
|
||||
<p><input type="image" src="//placehold.it/90x24" alt="input (image)"></p>
|
||||
<p><input type="button" value="input (button)"></p>
|
||||
<p><input type="file" value="input (file)"></p>
|
||||
<p><input type="reset" value="input (reset)"></p>
|
||||
<p><input type="submit" value="input (submit)"></p>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe">disabled <code>button</code> and <code>input</code></h2>
|
||||
<h3 class="Test-it">should have <code>default</code> cursor style</h3>
|
||||
<div class="Test-run">
|
||||
<p><button disabled>button</button></p>
|
||||
<p><input disabled type="button" value="input (button)"></p>
|
||||
<p><input disabled type="reset" value="input (reset)"></p>
|
||||
<p><input disabled type="submit" value="input (submit)"></p>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>button</code>, <code>input</code></h2>
|
||||
<h3 class="Test-it">should not have extra inner padding in Firefox</h3>
|
||||
<div class="Test-run" id="button-input-padding">
|
||||
<style>
|
||||
#button-input-padding button,
|
||||
#button-input-padding input {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
outline: 1px solid #ADD8E6;
|
||||
}
|
||||
</style>
|
||||
<p><button>button</button></p>
|
||||
<p><input type="button" value="input (button)"></p>
|
||||
<p><input type="reset" value="input (reset)"></p>
|
||||
<p><input type="submit" value="input (submit)"></p>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>fieldset</code></h2>
|
||||
<h3 class="Test-it">should have consistent border, padding, and margin</h3>
|
||||
<div class="Test-run">
|
||||
<fieldset>
|
||||
<div style="width:100%; height:100px; background:#ADD8E6;"></div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>legend</code></h2>
|
||||
<h3 class="Test-it">should inherit color</h3>
|
||||
<div class="Test-run" style="color:#ADD8E6;">
|
||||
<fieldset>
|
||||
<legend>legend</legend>
|
||||
</fieldset>
|
||||
</div>
|
||||
<h3 class="Test-it">should not have padding</h3>
|
||||
<div class="Test-run">
|
||||
<fieldset>
|
||||
<legend>legend</legend>
|
||||
</fieldset>
|
||||
</div>
|
||||
<h3 class="Test-it">should wrap text</h3>
|
||||
<div class="Test-run">
|
||||
<fieldset>
|
||||
<legend>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et me.</legend>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>textarea</code></h2>
|
||||
<h3 class="Test-it">should not have a scrollbar unless overflowing</h3>
|
||||
<div class="Test-run">
|
||||
<textarea>textarea</textarea>
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>[type="checkbox"]</code>, <code>[type="radio"]</code></h2>
|
||||
<h3 class="Test-it">should have a <code>border-box</code> box model</h3>
|
||||
<div class="Test-run Test-run--highlightEl" id="radio-box-model">
|
||||
<style>
|
||||
#radio-box-model {
|
||||
width: 200px;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
#radio-box-model input {
|
||||
width: 100%;
|
||||
border: 5px solid #ADD8E6;
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
<input type="checkbox">
|
||||
<input type="radio" name="rad">
|
||||
</div>
|
||||
<h3 class="Test-it">should not have padding</h3>
|
||||
<div class="Test-run Test-run--highlightEl">
|
||||
<input type="checkbox">
|
||||
<input type="radio" name="rad">
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>[type="number"]</code></h2>
|
||||
<h3 class="Test-it">should display a default cursor for the decrement button's click target in Chrome</h3>
|
||||
<div class="Test-run">
|
||||
<input style="height:50px; font-size:15px;" type="number" id="in" min="0" max="10" value="5">
|
||||
</div>
|
||||
|
||||
<h2 class="Test-describe"><code>[type="search"]</code></h2>
|
||||
<h3 class="Test-it">should be styleable</h3>
|
||||
<div class="Test-run">
|
||||
<input type="search" style="border:1px solid #ADD8E6; padding:10px; width:200px;">
|
||||
</div>
|
||||
<h3 class="Test-it">should reference inherited color</h3>
|
||||
<div class="Test-run">
|
||||
<input type="text" placeholder="Text goes here" style="background-color: black; color: orange;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,744 +0,0 @@
|
||||
<?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
|
||||
{
|
||||
public const ERROR_ILLEGAL_CHARACTER = 'iconv(): Detected an illegal character in input string';
|
||||
public 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 = [
|
||||
'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 = [];
|
||||
private static $convertMap = [];
|
||||
private static $errorHandler;
|
||||
private static $lastError;
|
||||
|
||||
private static $ulenMask = ["\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 = [];
|
||||
|
||||
$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]] = [$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 [
|
||||
'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 = [];
|
||||
}
|
||||
|
||||
$pref += [
|
||||
'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 = $chars[0] ?? [];
|
||||
|
||||
$lineBreak = (int) $pref['line-length'];
|
||||
$lineStart = "=?{$pref['output-charset']}?{$scheme}?";
|
||||
$lineLength = \strlen($fieldName) + 2 + \strlen($lineStart) + 2;
|
||||
$lineOffset = \strlen($lineStart) + 3;
|
||||
$lineData = '';
|
||||
|
||||
$fieldValue = [];
|
||||
|
||||
$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]/',
|
||||
[__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 += $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) {
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = 0;
|
||||
}
|
||||
if ($start >= $slen) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : false;
|
||||
}
|
||||
|
||||
$rx = $slen - $start;
|
||||
|
||||
if (0 > $length) {
|
||||
$length += $rx;
|
||||
}
|
||||
if (0 === $length) {
|
||||
return '';
|
||||
}
|
||||
if (0 > $length) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : 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 = $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;
|
||||
}
|
||||
|
||||
$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 = $ulenMask[$ulen] ?? 1;
|
||||
$uchr = substr($str, $i, $ulen);
|
||||
|
||||
if ($ignore && (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr)))) {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
|
||||
$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 = [];
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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.
|
||||
@@ -1,14 +0,0 @@
|
||||
Symfony Polyfill / Iconv
|
||||
========================
|
||||
|
||||
This component provides a native PHP implementation of the
|
||||
[php.net/iconv](https://php.net/iconv) functions
|
||||
(short of [`ob_iconv_handler`](https://php.net/ob-iconv-handler)).
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
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