Skip to content

Commit c85a4bf

Browse files
committed
Skip incomplete forms in nav header
1 parent d7f300a commit c85a4bf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Io/Loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public function loadXmlString($html)
3030
// - help link in footer not terminated
3131
// - selected branch/tag in CVS "sticky tag" dropdown has not attribute value
3232
// - self closing elements with no trailing slash
33-
// - excessive form close tags
33+
// - remove navheader because of its often incomplete form tags
3434
$html = str_replace('Help</strong></td>', 'Help</a></strong></td>', $html);
3535
$html = str_replace('selected>', 'selected="selected">', $html);
3636
$html = preg_replace('#<((?:input|br|hr|img)[^\/\>]*)>#', '<$1 />', $html);
37-
$html = preg_replace('#(</table>\s*)</form>\s*(</div>)#', '$1$2', $html);
37+
$html = preg_replace('#\<div class\=\"vc_navheader\"\>.*?\<\/div\>#s','', $html);
3838

3939
// replace named HTML entities with their UTF-8 value
4040
$html = str_replace(array_values($this->entities), array_keys($this->entities), $html);

tests/Io/LoaderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@ public function testLoadInvalidMarkupSelectedAttributeNoValue()
6060

6161
$this->assertEquals('selected', (string)$xml['selected']);
6262
}
63+
64+
public function testLoadRemovedNavHeader()
65+
{
66+
$str = '<body><div class="vc_navheader"> invalid <asd> </okay> </div> </body>';
67+
$xml = $this->loader->loadXmlString($str);
68+
69+
$this->assertFalse(isset($xml->div));
70+
$this->assertEquals(0, count($xml));
71+
}
6372
}

0 commit comments

Comments
 (0)