diff --git a/src/Io/Loader.php b/src/Io/Loader.php index f8e8a78..c0c028b 100644 --- a/src/Io/Loader.php +++ b/src/Io/Loader.php @@ -30,11 +30,11 @@ public function loadXmlString($html) // - help link in footer not terminated // - selected branch/tag in CVS "sticky tag" dropdown has not attribute value // - self closing elements with no trailing slash - // - excessive form close tags + // - remove navheader because of its often incomplete form tags $html = str_replace('Help', 'Help', $html); $html = str_replace('selected>', 'selected="selected">', $html); $html = preg_replace('#<((?:input|br|hr|img)[^\/\>]*)>#', '<$1 />', $html); - $html = preg_replace('#(\s*)\s*()#', '$1$2', $html); + $html = preg_replace('#\
.*?\<\/div\>#s','', $html); // replace named HTML entities with their UTF-8 value $html = str_replace(array_values($this->entities), array_keys($this->entities), $html); diff --git a/tests/Io/LoaderTest.php b/tests/Io/LoaderTest.php index 152297c..11e2124 100644 --- a/tests/Io/LoaderTest.php +++ b/tests/Io/LoaderTest.php @@ -60,4 +60,13 @@ public function testLoadInvalidMarkupSelectedAttributeNoValue() $this->assertEquals('selected', (string)$xml['selected']); } + + public function testLoadRemovedNavHeader() + { + $str = '
invalid
'; + $xml = $this->loader->loadXmlString($str); + + $this->assertFalse(isset($xml->div)); + $this->assertEquals(0, count($xml)); + } }