Tokenizer.php
2 years ago
TokenizerEscaping.php
2 years ago
TokenizerPatterns.php
2 years ago
index.php
2 years ago
TokenizerPatterns.php
62 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\Parser\Tokenizer; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class TokenizerPatterns |
| 5 | { |
| 6 | private $unicodeEscapePattern; |
| 7 | private $simpleEscapePattern; |
| 8 | private $newLineEscapePattern; |
| 9 | private $escapePattern; |
| 10 | private $stringEscapePattern; |
| 11 | private $nonAsciiPattern; |
| 12 | private $nmCharPattern; |
| 13 | private $nmStartPattern; |
| 14 | private $identifierPattern; |
| 15 | private $hashPattern; |
| 16 | private $numberPattern; |
| 17 | private $quotedStringPattern; |
| 18 | public function __construct() |
| 19 | { |
| 20 | $this->unicodeEscapePattern = '\\\\([0-9a-f]{1,6})(?:\\r\\n|[ \\n\\r\\t\\f])?'; |
| 21 | $this->simpleEscapePattern = '\\\\(.)'; |
| 22 | $this->newLineEscapePattern = '\\\\(?:\\n|\\r\\n|\\r|\\f)'; |
| 23 | $this->escapePattern = $this->unicodeEscapePattern . '|\\\\[^\\n\\r\\f0-9a-f]'; |
| 24 | $this->stringEscapePattern = $this->newLineEscapePattern . '|' . $this->escapePattern; |
| 25 | $this->nonAsciiPattern = '[^\\x00-\\x7F]'; |
| 26 | $this->nmCharPattern = '[_a-z0-9-]|' . $this->escapePattern . '|' . $this->nonAsciiPattern; |
| 27 | $this->nmStartPattern = '[_a-z]|' . $this->escapePattern . '|' . $this->nonAsciiPattern; |
| 28 | $this->identifierPattern = '-?(?:' . $this->nmStartPattern . ')(?:' . $this->nmCharPattern . ')*'; |
| 29 | $this->hashPattern = '#((?:' . $this->nmCharPattern . ')+)'; |
| 30 | $this->numberPattern = '[+-]?(?:[0-9]*\\.[0-9]+|[0-9]+)'; |
| 31 | $this->quotedStringPattern = '([^\\n\\r\\f\\\\%s]|' . $this->stringEscapePattern . ')*'; |
| 32 | } |
| 33 | public function getNewLineEscapePattern() : string |
| 34 | { |
| 35 | return '~' . $this->newLineEscapePattern . '~'; |
| 36 | } |
| 37 | public function getSimpleEscapePattern() : string |
| 38 | { |
| 39 | return '~' . $this->simpleEscapePattern . '~'; |
| 40 | } |
| 41 | public function getUnicodeEscapePattern() : string |
| 42 | { |
| 43 | return '~' . $this->unicodeEscapePattern . '~i'; |
| 44 | } |
| 45 | public function getIdentifierPattern() : string |
| 46 | { |
| 47 | return '~^' . $this->identifierPattern . '~i'; |
| 48 | } |
| 49 | public function getHashPattern() : string |
| 50 | { |
| 51 | return '~^' . $this->hashPattern . '~i'; |
| 52 | } |
| 53 | public function getNumberPattern() : string |
| 54 | { |
| 55 | return '~^' . $this->numberPattern . '~'; |
| 56 | } |
| 57 | public function getQuotedStringPattern(string $quote) : string |
| 58 | { |
| 59 | return '~^' . \sprintf($this->quotedStringPattern, $quote) . '~i'; |
| 60 | } |
| 61 | } |
| 62 |