Skip to content

Commit ae8c924

Browse files
committed
fix: Security patch when displaying the image size name not escaped.
1 parent e1ce66e commit ae8c924

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

classes/Admin/Media.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static function init() {
117117
// Add the setting field for this size.
118118
add_settings_field(
119119
'image_size_' . $s,
120-
sprintf( __( '%s size', 'simple-image-sizes' ), $s ),
120+
sprintf( __( '%s size', 'simple-image-sizes' ), esc_html( $s ) ),
121121
[
122122
__CLASS__,
123123
'image_sizes',
@@ -316,15 +316,15 @@ public static function a_add_size() {
316316
$croppings[ false ] = '';
317317

318318
// Check entries
319-
$name = isset( $_POST['name'] ) ? sanitize_title( $_POST['name'] ) : '';
319+
$name = isset( $_POST['name'] ) ? sanitize_text_field( sanitize_title( $_POST['name'] ) ) : '';
320320
$height = ! isset( $_POST['height'] ) ? 0 : absint( $_POST['height'] );
321321
$width = ! isset( $_POST['width'] ) ? 0 : absint( $_POST['width'] );
322-
$crop = isset( $_POST['crop'] ) && isset( $croppings[ $_POST['crop'] ] ) ? $_POST['crop'] : false;
323-
$show = isset( $_POST['show'] ) && $_POST['show'] == 'false' ? false : true;
322+
$crop = isset( $_POST['crop'] ) && isset( $croppings[ $_POST['crop'] ] ) ? (bool) $_POST['crop'] : false;
323+
$show = ! ( isset( $_POST['show'] ) && $_POST['show'] == 'false' );
324324
$cn = isset( $_POST['customName'] ) && ! empty( $_POST['customName'] ) ? sanitize_text_field( $_POST['customName'] ) : $name;
325325

326326
// Check the nonce
327-
if ( ! wp_verify_nonce( $nonce, 'add_size' ) ) {
327+
if ( ! wp_verify_nonce( $nonce, 'add_size' ) || ! current_user_can( 'manage_options' ) ) {
328328
die( 0 );
329329
}
330330

0 commit comments

Comments
 (0)