diff --git a/src/Helpers/Schedule/XmlParser.php b/src/Helpers/Schedule/XmlParser.php
index 0a1bebe0..27419820 100644
--- a/src/Helpers/Schedule/XmlParser.php
+++ b/src/Helpers/Schedule/XmlParser.php
@@ -15,8 +15,7 @@ class XmlParser
public function load(string $xml): bool
{
- $scheduleXML = simplexml_load_string($xml);
-
+ $scheduleXML = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOWARNING | LIBXML_NOERROR);
if (!$scheduleXML) {
return false;
}
diff --git a/tests/Unit/Helpers/Schedule/Assets/schedule-invalid.html b/tests/Unit/Helpers/Schedule/Assets/schedule-invalid.html
new file mode 100644
index 00000000..da99e808
--- /dev/null
+++ b/tests/Unit/Helpers/Schedule/Assets/schedule-invalid.html
@@ -0,0 +1,10 @@
+
+
+
+ I'm HTML!
+
+
+This is not a schedule
+and thus must be ignored.
+
+
diff --git a/tests/Unit/Helpers/Schedule/XmlParserTest.php b/tests/Unit/Helpers/Schedule/XmlParserTest.php
index 6a41b6d7..6af982bd 100644
--- a/tests/Unit/Helpers/Schedule/XmlParserTest.php
+++ b/tests/Unit/Helpers/Schedule/XmlParserTest.php
@@ -23,12 +23,13 @@ class XmlParserTest extends TestCase
*/
public function testLoad(): void
{
- libxml_use_internal_errors(true);
-
$parser = new XmlParser();
// Invalid XML
$this->assertFalse($parser->load('foo'));
+ // Invalid schedule
+ $this->assertFalse($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-invalid.html')));
+
// Minimal import
$this->assertTrue($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-minimal.xml')));
// Basic import