Browse Source

Avoid dynamic property creation

domparser
J. King 1 year ago
parent
commit
e11401d10d
  1. 2
      lib/Parser/AttributeSetter.php
  2. 8
      lib/Parser/Tokenizer.php
  3. 5
      lib/Parser/TreeConstructor.php

2
lib/Parser/AttributeSetter.php

@ -9,6 +9,8 @@ namespace MensBeam\HTML\Parser;
use MensBeam\HTML\Parser; use MensBeam\HTML\Parser;
trait AttributeSetter { trait AttributeSetter {
protected $mangledAttributes = false;
public function elementSetAttribute(\DOMElement $element, ?string $namespaceURI, string $qualifiedName, string $value): void { public function elementSetAttribute(\DOMElement $element, ?string $namespaceURI, string $qualifiedName, string $value): void {
if ($namespaceURI === Parser::XMLNS_NAMESPACE) { if ($namespaceURI === Parser::XMLNS_NAMESPACE) {
// NOTE: We create attribute nodes so that xmlns attributes // NOTE: We create attribute nodes so that xmlns attributes

8
lib/Parser/Tokenizer.php

@ -2873,7 +2873,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the empty string (not missing), # Set the DOCTYPE token's system identifier to the empty string (not missing),
# then switch to the DOCTYPE system identifier (double-quoted) state. # then switch to the DOCTYPE system identifier (double-quoted) state.
$this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS); $this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS);
$this->system = ''; $token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; $this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE;
} }
# "'" (U+0027) # "'" (U+0027)
@ -2882,7 +2882,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the empty string (not missing), # Set the DOCTYPE token's system identifier to the empty string (not missing),
# then switch to the DOCTYPE system identifier (single-quoted) state. # then switch to the DOCTYPE system identifier (single-quoted) state.
$this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS); $this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS);
$this->system = ''; $token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; $this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE;
} }
# EOF # EOF
@ -2932,7 +2932,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the # Set the DOCTYPE token's system identifier to the
# empty string (not missing), then switch to the # empty string (not missing), then switch to the
# DOCTYPE system identifier (double-quoted) state. # DOCTYPE system identifier (double-quoted) state.
$this->system = ''; $token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; $this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE;
} }
# "'" (U+0027) # "'" (U+0027)
@ -2940,7 +2940,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the # Set the DOCTYPE token's system identifier to the
# empty string (not missing), then switch to the # empty string (not missing), then switch to the
# DOCTYPE system identifier (single-quoted) state. # DOCTYPE system identifier (single-quoted) state.
$this->system = ''; $token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; $this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE;
} }
# EOF # EOF

5
lib/Parser/TreeConstructor.php

@ -35,7 +35,9 @@ class TreeConstructor {
protected $stack; protected $stack;
/** @var \MensBeam\HTML\Parser\Data Instance of the Data class used for reading the input character-stream */ /** @var \MensBeam\HTML\Parser\Data Instance of the Data class used for reading the input character-stream */
protected $data; protected $data;
/** @var \Generator Instance of the Tokenizer class used for creating tokens */ /** @var \Generator The output of the tokenizer */
protected $tokenList;
/** @var \MensBeam\HTML\Parser\Tokenizer Instance of the Tokenizer class used for creating tokens */
protected $tokenizer; protected $tokenizer;
/** @var \MensBeam\HTML\Parser\TemplateInsertionModesStack Used to store the template insertion modes */ /** @var \MensBeam\HTML\Parser\TemplateInsertionModesStack Used to store the template insertion modes */
protected $templateInsertionModes; protected $templateInsertionModes;
@ -3709,6 +3711,7 @@ class TreeConstructor {
# is lower in the stack than formatting element, and is an element in the # is lower in the stack than formatting element, and is an element in the
# special category. There might not be one. # special category. There might not be one.
$furthestBlock = null; $furthestBlock = null;
$furthestBlockIndex = null;
for ($k = ($stackIndex + 1); $k < count($this->stack); $k++) { for ($k = ($stackIndex + 1); $k < count($this->stack); $k++) {
if ($this->isElementSpecial($this->stack[$k])) { if ($this->isElementSpecial($this->stack[$k])) {
$furthestBlockIndex = $k; $furthestBlockIndex = $k;

Loading…
Cancel
Save