Skip to content

Commit f8b30a5

Browse files
committed
PHP: grab multiple characters at once when getting attribute name.
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401289
1 parent 9b3db4d commit f8b30a5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

library/HTML5/Tokenizer.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,13 @@ private function attributeNameState() {
865865
character (add 0x0020 to the character's code point) to
866866
the current attribute's name. Stay in the attribute name
867867
state. */
868+
$len = strspn($this->data, self::UPPER_ALPHA, $this->char + 1);
869+
$char = substr($this->data, $this->char + 1, $len);
870+
871+
$this->char += $len;
872+
868873
$last = count($this->token['attr']) - 1;
869-
$this->token['attr'][$last]['name'] .= strtolower($char);
874+
$this->token['attr'][$last]['name'] .= strtolower($this->c . $char);
870875

871876
$this->state = 'attributeName';
872877

@@ -887,8 +892,13 @@ private function attributeNameState() {
887892
/* Anything else
888893
Append the current input character to the current attribute's name.
889894
Stay in the attribute name state. */
895+
$len = strcspn($this->data, "\t\n\x0c /=>\"'" . self::UPPER_ALPHA, $this->char + 1);
896+
$char = substr($this->data, $this->char + 1, $len);
897+
898+
$this->char += $len;
899+
890900
$last = count($this->token['attr']) - 1;
891-
$this->token['attr'][$last]['name'] .= $char;
901+
$this->token['attr'][$last]['name'] .= $this->c . $char;
892902

893903
$this->state = 'attributeName';
894904
}

0 commit comments

Comments
 (0)