diff --git a/src/wp-includes/class-wp-icons-registry.php b/src/wp-includes/class-wp-icons-registry.php
index a10960da9a077..bbfa86782f628 100644
--- a/src/wp-includes/class-wp-icons-registry.php
+++ b/src/wp-includes/class-wp-icons-registry.php
@@ -261,6 +261,25 @@ protected function sanitize_icon_content( $icon_content ) {
'transform' => true,
'focusable' => true,
),
+ 'rect' => array(
+ 'fill' => true,
+ 'fill-rule' => true,
+ 'x' => true,
+ 'y' => true,
+ 'width' => true,
+ 'height' => true,
+ 'rx' => true,
+ 'ry' => true,
+ 'transform' => true,
+ ),
+ 'circle' => array(
+ 'fill' => true,
+ 'fill-rule' => true,
+ 'cx' => true,
+ 'cy' => true,
+ 'r' => true,
+ 'transform' => true,
+ ),
);
return wp_kses( $icon_content, $allowed_tags );
}
diff --git a/tests/phpunit/tests/icons/wpIconsRegistry.php b/tests/phpunit/tests/icons/wpIconsRegistry.php
index 42853d2666a95..18e92981f211c 100644
--- a/tests/phpunit/tests/icons/wpIconsRegistry.php
+++ b/tests/phpunit/tests/icons/wpIconsRegistry.php
@@ -453,4 +453,49 @@ public function test_get_content_returns_null_for_invalid_file( $contents, $exte
$this->assertNull( $icon['content'] );
}
+
+ /**
+ * Data provider.
+ *
+ * @return array[]
+ */
+ public function data_register_icon_preserves_rect_and_circle() {
+ return array(
+ 'rect' => array( '' ),
+ 'circle' => array( '' ),
+ );
+ }
+
+ /**
+ * Should preserve the `rect` and `circle` elements that library icons are drawn with.
+ *
+ * @ticket 66112
+ *
+ * @dataProvider data_register_icon_preserves_rect_and_circle
+ *
+ * @covers ::register
+ *
+ * @param string $shape Shape element the icon is drawn with.
+ */
+ public function test_register_icon_preserves_rect_and_circle( $shape ) {
+ $name = 'test-collection/shape-icon';
+
+ $this->assertTrue(
+ $this->registry->register(
+ $name,
+ array(
+ 'label' => 'Shape Icon',
+ 'content' => '',
+ )
+ )
+ );
+
+ $icon = $this->registry->get_registered_icon( $name );
+
+ $this->assertStringContainsString(
+ $shape,
+ $icon['content'],
+ 'Attributes were altered or stripped from the shape element.'
+ );
+ }
}