Skip to content

Commit 904a293

Browse files
committed
Merge pull request #13 from clue-labs/markup
Skip incomplete forms in nav header
2 parents 6bdb539 + c85a4bf commit 904a293

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
@@ -33,11 +33,11 @@ public function loadXmlString($html)
3333
// - help link in footer not terminated
3434
// - selected branch/tag in CVS "sticky tag" dropdown has not attribute value
3535
// - self closing elements with no trailing slash
36-
// - excessive form close tags
36+
// - remove navheader because of its often incomplete form tags
3737
$html = str_replace('Help</strong></td>', 'Help</a></strong></td>', $html);
3838
$html = str_replace('selected>', 'selected="selected">', $html);
3939
$html = preg_replace('#<((?:input|br|hr|img)[^\/\>]*)>#', '<$1 />', $html);
40-
$html = preg_replace('#(</table>\s*)</form>\s*(</div>)#', '$1$2', $html);
40+
$html = preg_replace('#\<div class\=\"vc_navheader\"\>.*?\<\/div\>#s','', $html);
4141

4242
// replace named HTML entities with their UTF-8 value
4343
$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
@@ -69,4 +69,13 @@ public function testLoadInvalidMarkupSelectedAttributeNoValue()
6969

7070
$this->assertEquals('selected', (string)$xml['selected']);
7171
}
72+
73+
public function testLoadRemovedNavHeader()
74+
{
75+
$str = '<body><div class="vc_navheader"> invalid <asd> </okay> </div> </body>';
76+
$xml = $this->loader->loadXmlString($str);
77+
78+
$this->assertFalse(isset($xml->div));
79+
$this->assertEquals(0, count($xml));
80+
}
7281
}

0 commit comments

Comments
 (0)