Merge pull request #1431 from dhensby/pulls/3.2/link-tracking-fix

FIX Link tracking not escaping `#`
This commit is contained in:
Damian Mooyman 2016-03-22 17:57:56 +13:00
commit cf0a19e5a6
2 changed files with 3 additions and 1 deletions

View File

@ -259,12 +259,13 @@ class SiteTreeLinkTracking_Parser {
// Local anchor.
$matches = array();
if(preg_match('/^#(.*)/i', $href, $matches)) {
$anchor = preg_quote($matches[1], '#');
$results[] = array(
'Type' => 'localanchor',
'Target' => null,
'Anchor' => $matches[1],
'DOMReference' => $link,
'Broken' => !preg_match("#(name|id)=\"{$matches[1]}\"#", $htmlValue->getContent())
'Broken' => !preg_match("#(name|id)=\"{$anchor}\"#", $htmlValue->getContent())
);
continue;

View File

@ -20,6 +20,7 @@ class SiteTreeLinkTrackingTest extends SapphireTest {
$this->assertFalse($this->isBroken('<a name="anchor">anchor</a>'));
$this->assertFalse($this->isBroken('<a id="anchor">anchor</a>'));
$this->assertTrue($this->isBroken('<a href="##anchor">anchor</a>'));
$page = new Page();
$page->Content = '<a name="yes-name-anchor">name</a><a id="yes-id-anchor">id</a>';