mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge remote-tracking branch 'origin/3.2' into 3.3
This commit is contained in:
commit
e706b147cc
@ -217,14 +217,18 @@ class SiteTreeLinkTracking_Parser {
|
||||
$matches = array();
|
||||
if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=([0-9]+)\](#(.*))?/i', $href, $matches)) {
|
||||
$page = DataObject::get_by_id('SiteTree', $matches[1]);
|
||||
$broken = false;
|
||||
|
||||
if (!$page) {
|
||||
// Page doesn't exist.
|
||||
$broken = true;
|
||||
} else if (!empty($matches[3]) && !preg_match("/(name|id)=\"{$matches[3]}\"/", $page->Content)) {
|
||||
// Broken anchor on the target page.
|
||||
$broken = true;
|
||||
} else {
|
||||
$broken = false;
|
||||
} else if (!empty($matches[3])) {
|
||||
$anchor = preg_quote($matches[3], '/');
|
||||
|
||||
if (!preg_match("/(name|id)=\"{$anchor}\"/", $page->Content)) {
|
||||
// Broken anchor on the target page.
|
||||
$broken = true;
|
||||
}
|
||||
}
|
||||
|
||||
$results[] = array(
|
||||
|
@ -57,6 +57,10 @@ So that I can link to a external website or a page on my site
|
||||
Then the "Content" HTML field should contain "<a href="[file_link,id=3]" target="_blank">awesome</a>"
|
||||
# Required to avoid "unsaved changes" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
# Check that the field is reset when adding another new link
|
||||
Given I select "content" in the "Content" HTML field
|
||||
When I press the "Insert Link" button
|
||||
Then I should not see a ".ss-uploadfield-files .ss-uploadfield-item" element
|
||||
|
||||
Scenario: I can link to an anchor
|
||||
Given I fill in the "Content" HTML field with "<p>My awesome content<a name='myanchor'></a></p>"
|
||||
|
@ -32,6 +32,7 @@ class SiteTreeLinkTrackingTest extends SapphireTest {
|
||||
$this->assertFalse($this->isBroken("<a href=\"[sitetree_link,id=$page->ID]#yes-name-anchor\">link</a>"));
|
||||
$this->assertFalse($this->isBroken("<a href=\"[sitetree_link,id=$page->ID]#yes-id-anchor\">link</a>"));
|
||||
$this->assertFalse($this->isBroken("<a href=\"[file_link,id=$file->ID]\">link</a>"));
|
||||
$this->assertTrue($this->isBroken("<a href=\"[sitetree_link,id=$page->ID]#http://invalid-anchor.com\"></a>"));
|
||||
}
|
||||
|
||||
function highlight($content) {
|
||||
|
Loading…
Reference in New Issue
Block a user