diff --git a/src/Io/Loader.php b/src/Io/Loader.php
index 4fef28d..f8e8a78 100644
--- a/src/Io/Loader.php
+++ b/src/Io/Loader.php
@@ -29,10 +29,12 @@ public function loadXmlString($html)
// fix invalid markup of outdated ViewVC versions
// - help link in footer not terminated
// - selected branch/tag in CVS "sticky tag" dropdown has not attribute value
- // - clear button for selected branch/tag has no trailing slash
+ // - self closing elements with no trailing slash
+ // - excessive form close tags
$html = str_replace('Help', 'Help', $html);
$html = str_replace('selected>', 'selected="selected">', $html);
- $html = preg_replace('##', '', $html);
+ $html = preg_replace('#<((?:input|br|hr|img)[^\/\>]*)>#', '<$1 />', $html);
+ $html = preg_replace('#(\s*)\s*()#', '$1$2', $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 53946db..152297c 100644
--- a/tests/Io/LoaderTest.php
+++ b/tests/Io/LoaderTest.php
@@ -47,6 +47,12 @@ public function testLoadInvalidMarkupInputNotClosed()
$this->assertEquals('hidden', (string)$xml['type']);
}
+ public function testPrepareInvalidMarkupBrNotClosed()
+ {
+ $html = '
';
+ $xml = $this->loader->loadXmlString($html);
+ }
+
public function testLoadInvalidMarkupSelectedAttributeNoValue()
{
$str = '';