diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php
index 25a97baa..47cf8bae 100644
--- a/code/model/SiteTree.php
+++ b/code/model/SiteTree.php
@@ -1380,7 +1380,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
public function MetaTags($includeTitle = true) {
$tags = "";
if($includeTitle === true || $includeTitle == 'true') {
- $tags .= "
" . $this->Title . "\n";
+ $tags .= "" . Convert::raw2xml($this->Title) . "\n";
}
$generator = trim(Config::inst()->get('SiteTree', 'meta_generator'));
diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php
index e4e8d4ce..7f0dda50 100644
--- a/tests/model/SiteTreeTest.php
+++ b/tests/model/SiteTreeTest.php
@@ -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 )
+ */
+ 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('assertContains('assertContains('assertContains('assertContains('', $meta);
+ $this->assertContains('HTML & XML', $meta);
+
+ // Test without title
+ $meta = $page->MetaTags(false);
+ $this->assertNotContains('', $meta);
+ }
+
/**
* Test that orphaned pages are handled correctly
*/
diff --git a/tests/model/SiteTreeTest.yml b/tests/model/SiteTreeTest.yml
index 070e2228..2f0cf282 100644
--- a/tests/model/SiteTreeTest.yml
+++ b/tests/model/SiteTreeTest.yml
@@ -1,104 +1,107 @@
Group:
- editors:
- Title: Editors
- admins:
- Title: Administrators
- allsections:
- Title: All Section Editors
- securityadmins:
- Title: Security Admins
+ editors:
+ Title: Editors
+ admins:
+ Title: Administrators
+ allsections:
+ Title: All Section Editors
+ securityadmins:
+ Title: Security Admins
Permission:
- admins:
- Code: ADMIN
- Group: =>Group.admins
- editors:
- Code: CMS_ACCESS_CMSMain
- Group: =>Group.editors
- allsections:
- Code: CMS_ACCESS_LeftAndMain
- Group: =>Group.allsections
- securityadmins:
- Code: CMS_ACCESS_SecurityAdmin
- Group: =>Group.securityadmins
+ admins:
+ Code: ADMIN
+ Group: =>Group.admins
+ editors:
+ Code: CMS_ACCESS_CMSMain
+ Group: =>Group.editors
+ allsections:
+ Code: CMS_ACCESS_LeftAndMain
+ Group: =>Group.allsections
+ securityadmins:
+ Code: CMS_ACCESS_SecurityAdmin
+ Group: =>Group.securityadmins
Member:
- editor:
- FirstName: Test
- Surname: Editor
- Groups: =>Group.editors
- admin:
- FirstName: Test
- Surname: Administrator
- Groups: =>Group.admins
- allsections:
- Groups: =>Group.allsections
- securityadmin:
- Groups: =>Group.securityadmins
+ editor:
+ FirstName: Test
+ Surname: Editor
+ Groups: =>Group.editors
+ admin:
+ FirstName: Test
+ Surname: Administrator
+ Groups: =>Group.admins
+ allsections:
+ Groups: =>Group.allsections
+ securityadmin:
+ Groups: =>Group.securityadmins
Page:
- home:
- Title: Home
- CanEditType: OnlyTheseUsers
- EditorGroups: =>Group.admins
- about:
- Title: About Us
- CanEditType: OnlyTheseUsers
- EditorGroups: =>Group.admins
- staff:
- Title: Staff
- URLSegment: my-staff
- Parent: =>Page.about
- ceo:
- Title: CEO
- Parent: =>Page.staff
- staffduplicate:
- Title: Staff
- URLSegment: my-staff
- Parent: =>Page.about
- products:
- Title: Products
- CanEditType: OnlyTheseUsers
- EditorGroups: =>Group.editors
- product1:
- Title: 1.1 Test Product
- Parent: =>Page.products
- CanEditType: Inherit
- product2:
- Title: Another Product
- Parent: =>Page.products
- CanEditType: Inherit
- product3:
- Title: Another Product
- Parent: =>Page.products
- CanEditType: Inherit
- product4:
- Title: Another Product
- Parent: =>Page.products
- CanEditType: OnlyTheseUsers
- EditorGroups: =>Group.admins
- contact:
- Title: Contact Us
- object:
- Title: Object
- controller:
- Title: Controller
- numericonly:
- Title: 1930
+ home:
+ Title: Home
+ CanEditType: OnlyTheseUsers
+ EditorGroups: =>Group.admins
+ about:
+ Title: About Us
+ CanEditType: OnlyTheseUsers
+ EditorGroups: =>Group.admins
+ staff:
+ Title: Staff
+ URLSegment: my-staff
+ Parent: =>Page.about
+ ceo:
+ Title: CEO
+ Parent: =>Page.staff
+ staffduplicate:
+ Title: Staff
+ URLSegment: my-staff
+ Parent: =>Page.about
+ products:
+ Title: Products
+ CanEditType: OnlyTheseUsers
+ EditorGroups: =>Group.editors
+ product1:
+ Title: 1.1 Test Product
+ Parent: =>Page.products
+ CanEditType: Inherit
+ product2:
+ Title: Another Product
+ Parent: =>Page.products
+ CanEditType: Inherit
+ product3:
+ Title: Another Product
+ Parent: =>Page.products
+ CanEditType: Inherit
+ product4:
+ Title: Another Product
+ Parent: =>Page.products
+ CanEditType: OnlyTheseUsers
+ EditorGroups: =>Group.admins
+ contact:
+ Title: Contact Us
+ object:
+ Title: Object
+ controller:
+ Title: Controller
+ numericonly:
+ Title: 1930
+ metapage:
+ Title: 'HTML & XML'
+ MetaDescription: 'The
and
tags'
+ ExtraMeta: ''
SiteTreeTest_Conflicted:
- parent:
- Title: Parent
+ parent:
+ Title: Parent
ErrorPage:
- 404:
- Title: Page not Found
- ErrorCode: 404
+ 404:
+ Title: Page not Found
+ ErrorCode: 404
RedirectorPage:
- external:
- Title: External
- URLSegment: external
- RedirectionType: External
- ExternalURL: "http://www.google.com?a&b"
-
+ external:
+ Title: External
+ URLSegment: external
+ RedirectionType: External
+ ExternalURL: "http://www.google.com?a&b"