From 30bb3d2c33205336a7ad00793a38f5922164ad45 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 18 Dec 2024 11:25:07 +1300 Subject: [PATCH] FIX Apply raw2xml before extension hook --- src/ORM/Hierarchy/Hierarchy.php | 3 ++- tests/php/ORM/HierarchyTest.php | 10 ++++++++++ .../ORM/HierarchyTest/TestTreeTitleExtension.php | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/php/ORM/HierarchyTest/TestTreeTitleExtension.php diff --git a/src/ORM/Hierarchy/Hierarchy.php b/src/ORM/Hierarchy/Hierarchy.php index c9eff0c8183..d92f3588c6d 100644 --- a/src/ORM/Hierarchy/Hierarchy.php +++ b/src/ORM/Hierarchy/Hierarchy.php @@ -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; } /** diff --git a/tests/php/ORM/HierarchyTest.php b/tests/php/ORM/HierarchyTest.php index 4a367f5db3e..0bf262d8b77 100644 --- a/tests/php/ORM/HierarchyTest.php +++ b/tests/php/ORM/HierarchyTest.php @@ -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', 'Obj 1'); + } } diff --git a/tests/php/ORM/HierarchyTest/TestTreeTitleExtension.php b/tests/php/ORM/HierarchyTest/TestTreeTitleExtension.php new file mode 100644 index 00000000000..57d01883ed1 --- /dev/null +++ b/tests/php/ORM/HierarchyTest/TestTreeTitleExtension.php @@ -0,0 +1,14 @@ +$title"; + } +}