Skip to content

Commit 5fb0b2d

Browse files
committed
Avoid Scanner::peek reading beyond end of data
Masterminds\HTML5\Parser\Scanner::peek() reads beyond the end of actual data, which leads to a "Uninitialized string offset" warning. Fixes: #215
1 parent d3786d4 commit 5fb0b2d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/HTML5/Parser/Scanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function position()
104104
*/
105105
public function peek()
106106
{
107-
if (($this->char + 1) <= $this->EOF) {
107+
if (($this->char + 1) < $this->EOF) {
108108
return $this->data[$this->char + 1];
109109
}
110110

test/HTML5/Parser/TokenizerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ public function testComment()
213213
'<!--Hello' => 'Hello',
214214
"<!--\0Hello" => UTF8Utils::FFFD . 'Hello',
215215
'<!--' => '',
216+
'<!--<!--' => '<!--',
216217
);
217218
foreach ($fail as $test => $expected) {
218219
$events = $this->parse($test);

0 commit comments

Comments
 (0)