← All changes
|
vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
+10
-7
3.0.0
→
3.2.90
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace WindPressPackages\Masterminds\HTML5\Parser; | |
| 3 | +namespace WindPressDeps\Masterminds\HTML5\Parser; | |
| 4 | 4 | |
| 5 | -use WindPressPackages\Masterminds\HTML5\Elements; | |
| 5 | +use WindPressDeps\Masterminds\HTML5\Elements; | |
| 6 | 6 | /** |
| 7 | 7 | * The HTML5 tokenizer. |
| 8 | 8 | * |
| 9 | 9 | * The tokenizer's role is reading data from the scanner and gathering it into |
| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | } |
| 314 | 314 | return $this->bogusComment('</'); |
| 315 | 315 | } |
| 316 | 316 | $name = $this->scanner->charsUntil("\n\f \t>"); |
| 317 | - $name = (self::CONFORMANT_XML === $this->mode) ? $name : strtolower($name); | |
| 317 | + $name = self::CONFORMANT_XML === $this->mode ? $name : strtolower($name); | |
| 318 | 318 | // Trash whitespace. |
| 319 | 319 | $this->scanner->whitespace(); |
| 320 | 320 | $tok = $this->scanner->current(); |
| 321 | 321 | if ('>' != $tok) { |
| @@ -333,9 +333,9 @@ | ||
| 333 | 333 | protected function tagName() |
| 334 | 334 | { |
| 335 | 335 | // We know this is at least one char. |
| 336 | 336 | $name = $this->scanner->charsWhile(':_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'); |
| 337 | - $name = (self::CONFORMANT_XML === $this->mode) ? $name : strtolower($name); | |
| 337 | + $name = self::CONFORMANT_XML === $this->mode ? $name : strtolower($name); | |
| 338 | 338 | $attributes = array(); |
| 339 | 339 | $selfClose = \false; |
| 340 | 340 | // Handle attribute parse exceptions here so that we can |
| 341 | 341 | // react by trying to build a sensible parse tree. |
| @@ -432,9 +432,9 @@ | ||
| 432 | 432 | } |
| 433 | 433 | // 8.1.2.3 |
| 434 | 434 | $this->scanner->whitespace(); |
| 435 | 435 | $val = $this->attributeValue(); |
| 436 | - if ($isValidAttribute) { | |
| 436 | + if ($isValidAttribute && !array_key_exists($name, $attributes)) { | |
| 437 | 437 | $attributes[$name] = $val; |
| 438 | 438 | } |
| 439 | 439 | return \true; |
| 440 | 440 | } |
| @@ -692,9 +692,9 @@ | ||
| 692 | 692 | $white = $this->scanner->whitespace(); |
| 693 | 693 | // Get ID, and flag it as pub or system. |
| 694 | 694 | if (('PUBLIC' == $pub || 'SYSTEM' == $pub) && $white > 0) { |
| 695 | 695 | // Get the sys ID. |
| 696 | - $type = ('PUBLIC' == $pub) ? EventHandler::DOCTYPE_PUBLIC : EventHandler::DOCTYPE_SYSTEM; | |
| 696 | + $type = 'PUBLIC' == $pub ? EventHandler::DOCTYPE_PUBLIC : EventHandler::DOCTYPE_SYSTEM; | |
| 697 | 697 | $id = $this->quotedString("\x00>"); |
| 698 | 698 | if (\false === $id) { |
| 699 | 699 | $this->events->doctype($doctypeName, $type, $pub, \false); |
| 700 | 700 | return \true; |
| @@ -955,9 +955,9 @@ | ||
| 955 | 955 | $this->parseError('Expected &#DEC; &#HEX;, got EOF'); |
| 956 | 956 | $this->scanner->unconsume(1); |
| 957 | 957 | return '&'; |
| 958 | 958 | } |
| 959 | - // Hexidecimal encoding. | |
| 959 | + // Hexadecimal encoding. | |
| 960 | 960 | // X[0-9a-fA-F]+; |
| 961 | 961 | // x[0-9a-fA-F]+; |
| 962 | 962 | if ('x' === $tok || 'X' === $tok) { |
| 963 | 963 | $tok = $this->scanner->next(); |
| @@ -1023,8 +1023,11 @@ | ||
| 1023 | 1023 | * @return bool True if it is a letter, False otherwise |
| 1024 | 1024 | */ |
| 1025 | 1025 | protected function is_alpha($input) |
| 1026 | 1026 | { |
| 1027 | + if (!is_string($input) || 1 !== strlen($input)) { | |
| 1028 | + return \false; | |
| 1029 | + } | |
| 1027 | 1030 | $code = ord($input); |
| 1028 | 1031 | return $code >= 97 && $code <= 122 || $code >= 65 && $code <= 90; |
| 1029 | 1032 | } |
| 1030 | 1033 | } |