Skip to content
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

FIX Apply raw2xml before extension hook #11516

Closed
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
3 changes: 2 additions & 1 deletion src/ORM/Hierarchy/Hierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,9 @@ public function getTreeTitle(): string
{
$owner = $this->getOwner();
$title = $owner->MenuTitle ?: $owner->Title;
$title = Convert::raw2xml($title ?? '');
$owner->extend('updateTreeTitle', $title);
return Convert::raw2xml($title ?? '');
return $title;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/php/ORM/HierarchyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,14 @@ public function testDefaultParent(string $class, ?string $defaultParentConfig, ?

$this->assertSame($expected, $obj->defaultParent());
}

/**
* Tests that HTML added by an extension is not escaped
*/
public function testGetTreeTitleExtension()
{
HierarchyTest\TestObject::add_extension(HierarchyTest\TestTreeTitleExtension::class);
$obj = $this->objFromFixture(HierarchyTest\TestObject::class, 'obj1');
$this->assertSame('Obj 1', '<i>Obj 1</i>');
}
}
14 changes: 14 additions & 0 deletions tests/php/ORM/HierarchyTest/TestTreeTitleExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace SilverStripe\ORM\Tests\HierarchyTest;

use SilverStripe\Dev\TestOnly;
use SilverStripe\Core\Extension;

class TestTreeTitleExtension extends Extension implements TestOnly
{
protected function updateTreeTitle(string &$title)
{
return "<i>$title</i>";
}
}
Loading