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;
trait AttributeSetter {
protected $mangledAttributes = false;
public function elementSetAttribute(\DOMElement $element, ?string $namespaceURI, string $qualifiedName, string $value): void {
if ($namespaceURI === Parser::XMLNS_NAMESPACE) {
// 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),
# then switch to the DOCTYPE system identifier (double-quoted) state.
$this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS);
$this->system = '';
$token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE;
}
# "'" (U+0027)
@ -2882,7 +2882,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the empty string (not missing),
# then switch to the DOCTYPE system identifier (single-quoted) state.
$this->error(ParseError::MISSING_WHITESPACE_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS);
$this->system = '';
$token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE;
}
# EOF
@ -2932,7 +2932,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the
# empty string (not missing), then switch to the
# DOCTYPE system identifier (double-quoted) state.
$this->system = '';
$token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE;
}
# "'" (U+0027)
@ -2940,7 +2940,7 @@ class Tokenizer {
# Set the DOCTYPE token's system identifier to the
# empty string (not missing), then switch to the
# DOCTYPE system identifier (single-quoted) state.
$this->system = '';
$token->system = '';
$this->state = self::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE;
}
# EOF

5
lib/Parser/TreeConstructor.php

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

Loading…
Cancel
Save