Skip to content

Commit d9686ce

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 50d7c52 + 7a7652e commit d9686ce

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/wp-includes/block-supports/layout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function wp_get_layout_container_values( $layout ) {
8686
function wp_sanitize_block_gap_value( $gap_value ) {
8787
if ( is_array( $gap_value ) ) {
8888
foreach ( $gap_value as $key => $value ) {
89-
$gap_value[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
89+
$gap_value[ $key ] = ! is_scalar( $value ) || ( $value && preg_match( '%[\\\(&=}]|/\*%', (string) $value ) ) ? null : $value;
9090
}
9191

9292
return $gap_value;

tests/phpunit/tests/block-supports/layout.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ public function filter_set_theme_root() {
8282
return $this->theme_root;
8383
}
8484

85+
/**
86+
* @ticket 65667
87+
*
88+
* @covers ::wp_sanitize_block_gap_value
89+
*/
90+
public function test_sanitize_block_gap_value_rejects_nested_array_values() {
91+
$this->assertSame(
92+
array(
93+
'top' => null,
94+
'left' => '2rem',
95+
),
96+
wp_sanitize_block_gap_value(
97+
array(
98+
'top' => array( '1rem' ),
99+
'left' => '2rem',
100+
)
101+
)
102+
);
103+
}
104+
85105
/**
86106
* @ticket 55505
87107
*/
@@ -235,6 +255,32 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() {
235255
),
236256
'expected_output' => '<div class="wp-block-group is-layout-flow wp-block-group-is-layout-flow"></div>',
237257
),
258+
'single wrapper block layout with malformed axial block gap' => array(
259+
'args' => array(
260+
'block_content' => '<div class="wp-block-group"></div>',
261+
'block' => array(
262+
'blockName' => 'core/group',
263+
'attrs' => array(
264+
'layout' => array(
265+
'type' => 'default',
266+
),
267+
'style' => array(
268+
'spacing' => array(
269+
'blockGap' => array(
270+
'top' => array( '1rem' ),
271+
),
272+
),
273+
),
274+
),
275+
'innerBlocks' => array(),
276+
'innerHTML' => '<div class="wp-block-group"></div>',
277+
'innerContent' => array(
278+
'<div class="wp-block-group"></div>',
279+
),
280+
),
281+
),
282+
'expected_output' => '<div class="wp-block-group is-layout-flow wp-block-group-is-layout-flow"></div>',
283+
),
238284
'single wrapper block layout with constrained type' => array(
239285
'args' => array(
240286
'block_content' => '<div class="wp-block-group"></div>',

0 commit comments

Comments
 (0)