Skip to content

Commit 4bd22bf

Browse files
committed
Sanitize block support styles before outputing them
1 parent a816be9 commit 4bd22bf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

includes/Blocks/SharedBlock.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,21 @@ public function render_callback( $attributes, $content, $block ): string {
121121
add_action(
122122
$action_hook_name,
123123
function () use ( $block_support_styles ) {
124-
echo $block_support_styles; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
124+
$block_support_styles = preg_replace(
125+
'@<(script)[^>]*?>.*?</\\1>@si',
126+
'',
127+
$block_support_styles
128+
);
129+
echo wp_kses(
130+
$block_support_styles,
131+
[
132+
'style' => [
133+
'nonce' => true,
134+
'media' => true,
135+
'title' => true,
136+
],
137+
]
138+
);
125139
}
126140
);
127141
}

0 commit comments

Comments
 (0)