Skip to content

Commit aa57e1a

Browse files
committed
1 parent 41df0a5 commit aa57e1a

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

src/Parser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ public function parse(Source $source)
166166
$this->add($token);
167167
}
168168

169-
if ($this->buildingNode) {
169+
if ($this->buildingNode instanceof DomNode) {
170+
throw new UnclosedTagException("Unexpected end of the document, expecting end tag for node '". $this->buildingNode->getNodeName() ."' started at line {$this->buildingNode->meta['line']}", (string)$this->file, $this->buildingNode->meta['line']);
171+
}
172+
elseif ($this->buildingNode) {
170173
$this->dom->appendChild($this->buildingNode);
171174
}
172175

src/Source.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Source
1313

1414
public function __construct(string $code, string $file, int $startLine = 0)
1515
{
16+
if ($file) {
17+
$file = realpath($file);
18+
}
19+
1620
$this->code = $code;
1721
$this->file = $file;
1822
$this->startLine = $startLine;

tests/error_cases/2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
=====
88

9-
a/b/3
9+
Unexpected token/2.html/3

tests/error_cases/3.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div <>
2+
3+
4+
</div>
5+
6+
=====
7+
8+
unexpected token/3.html/1

tests/error_cases/4.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="<div> <fii>
2+
3+
</fii></div>></div>
4+
5+
=====
6+
7+
end of the document/4.html/1

0 commit comments

Comments
 (0)