Skip to content

Skip incomplete forms in nav header #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Io/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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</strong></td>', 'Help</a></strong></td>', $html);
$html = str_replace('selected>', 'selected="selected">', $html);
$html = preg_replace('#<((?:input|br|hr|img)[^\/\>]*)>#', '<$1 />', $html);
$html = preg_replace('#(</table>\s*)</form>\s*(</div>)#', '$1$2', $html);
$html = preg_replace('#\<div class\=\"vc_navheader\"\>.*?\<\/div\>#s','', $html);

// replace named HTML entities with their UTF-8 value
$html = str_replace(array_values($this->entities), array_keys($this->entities), $html);
Expand Down
9 changes: 9 additions & 0 deletions tests/Io/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ public function testLoadInvalidMarkupSelectedAttributeNoValue()

$this->assertEquals('selected', (string)$xml['selected']);
}

public function testLoadRemovedNavHeader()
{
$str = '<body><div class="vc_navheader"> invalid <asd> </okay> </div> </body>';
$xml = $this->loader->loadXmlString($str);

$this->assertFalse(isset($xml->div));
$this->assertEquals(0, count($xml));
}
}