Skip to content

Commit 86d8c52

Browse files
authored
Merge pull request #559 from sash04ek/patch-2
Handle Vobjects without closing tag
2 parents 3d5eda5 + ccaec1c commit 86d8c52

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/Parser/MimeDir.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ protected function parseDocument()
167167

168168
while (true) {
169169
// Reading until we hit END:
170-
$line = $this->readLine();
170+
try {
171+
$line = $this->readLine();
172+
} catch (EofException $oEx) {
173+
$line = 'END:'.$this->root->name;
174+
}
171175
if ('END:' === strtoupper(substr($line, 0, 4))) {
172176
break;
173177
}

tests/VObject/ReaderTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,16 @@ public function testReadMappedPropertyGrouped()
114114
$this->assertEquals('20110529', $result->getValue());
115115
}
116116

117-
public function testReadBrokenLine()
117+
public function testReadMissingEnd()
118118
{
119-
$this->expectException(ParseException::class);
120-
$data = "BEGIN:VCALENDAR\r\nPROPNAME;propValue";
119+
$data = "BEGIN:VCALENDAR\r\nPROPNAME:propValue";
121120
$result = Reader::read($data);
121+
$this->assertInstanceOf(Component::class, $result);
122+
$this->assertEquals('VCALENDAR', $result->name);
123+
$this->assertEquals(1, count($result->children()));
124+
$this->assertInstanceOf(Property::class, $result->children()[0]);
125+
$this->assertEquals('PROPNAME', $result->children()[0]->name);
126+
$this->assertEquals('propValue', $result->children()[0]->getValue());
122127
}
123128

124129
public function testReadPropertyInComponent()

0 commit comments

Comments
 (0)