mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUG Fix encoding of SiteTree.MetaTags
This commit is contained in:
parent
9bff36c078
commit
89fbae2c2e
@ -1380,7 +1380,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
public function MetaTags($includeTitle = true) {
|
||||
$tags = "";
|
||||
if($includeTitle === true || $includeTitle == 'true') {
|
||||
$tags .= "<title>" . $this->Title . "</title>\n";
|
||||
$tags .= "<title>" . Convert::raw2xml($this->Title) . "</title>\n";
|
||||
}
|
||||
|
||||
$generator = trim(Config::inst()->get('SiteTree', 'meta_generator'));
|
||||
|
@ -944,6 +944,29 @@ class SiteTreeTest extends SapphireTest {
|
||||
Config::inst()->update('SiteTree', 'meta_generator', $generator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests SiteTree::MetaTags
|
||||
* Note that this test makes no assumption on the closing of tags (other than <title></title>)
|
||||
*/
|
||||
public function testMetaTags() {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$page = $this->objFromFixture('Page', 'metapage');
|
||||
|
||||
// Test with title
|
||||
$meta = $page->MetaTags();
|
||||
$charset = Config::inst()->get('ContentNegotiator', 'encoding');
|
||||
$this->assertContains('<meta http-equiv="Content-type" content="text/html; charset='.$charset.'"', $meta);
|
||||
$this->assertContains('<meta name="description" content="The <br /> and <br> tags"', $meta);
|
||||
$this->assertContains('<link rel="canonical" href="http://www.mysite.com/html-and-xml"', $meta);
|
||||
$this->assertContains('<meta name="x-page-id" content="'.$page->ID.'"', $meta);
|
||||
$this->assertContains('<meta name="x-cms-edit-link" content="'.$page->CMSEditLink().'" />', $meta);
|
||||
$this->assertContains('<title>HTML & XML</title>', $meta);
|
||||
|
||||
// Test without title
|
||||
$meta = $page->MetaTags(false);
|
||||
$this->assertNotContains('<title>', $meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that orphaned pages are handled correctly
|
||||
*/
|
||||
|
@ -85,6 +85,10 @@ Page:
|
||||
Title: Controller
|
||||
numericonly:
|
||||
Title: 1930
|
||||
metapage:
|
||||
Title: 'HTML & XML'
|
||||
MetaDescription: 'The <br /> and <br> tags'
|
||||
ExtraMeta: '<link rel="canonical" href="http://www.mysite.com/html-and-xml" />'
|
||||
|
||||
SiteTreeTest_Conflicted:
|
||||
parent:
|
||||
@ -101,4 +105,3 @@ RedirectorPage:
|
||||
URLSegment: external
|
||||
RedirectionType: External
|
||||
ExternalURL: "http://www.google.com?a&b"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user