Make WordPress Core

Opened 2 months ago

Last modified 7 weeks ago

#64280 new defect (bug)

Unable to change the lightbox settings of the Image block within Global Styles when KSES is active

Reported by: ramonopoly's profile ramonopoly Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version: 6.4
Component: Themes Keywords: has-patch has-unit-tests gutenberg-merge
Focuses: Cc:

Description

This ticket corresponds to the bug report in https://github.com/WordPress/gutenberg/issues/73157

When KSES filters are active (via add_action( 'init', 'kses_init_filters' )), valid non-preset settings in Global Styles are being incorrectly filtered out. Specifically:

  • lightbox.enabled and lightbox.allowEditing for Image blocks

The issue occurs because remove_insecure_settings() only preserved:

  1. Presets (from PRESETS_METADATA)
  2. Indirect CSS properties (from INDIRECT_PROPERTIES_METADATA)

Step-by-step reproduction instructions

  1. Enable the KSES filters with add_action( 'init', 'kses_init_filters' );
  2. Go to Appearance > Editor
  3. Open the Styles sidebar
  4. Select "Blocks"
  5. Select "Image"
  6. Change the "Enlarge on click" options
  7. Save the changes

⚠️ Note how the changes are reverted

Change History (6)

This ticket was mentioned in PR #10534 on WordPress/wordpress-develop by @ramonopoly.


2 months ago
#1

A PR to sync https://github.com/WordPress/gutenberg/pull/73452

## Problem

When KSES filters are active (via add_action( 'init', 'kses_init_filters' )), valid non-preset settings in Global Styles are being incorrectly filtered out. Specifically:

  • lightbox.enabled and lightbox.allowEditing for Image blocks

The issue occurs because remove_insecure_settings() only preserved:

  1. Presets (from PRESETS_METADATA)
  2. Indirect CSS properties (from INDIRECT_PROPERTIES_METADATA)

All other valid settings were being stripped, even though they're defined in VALID_SETTINGS and are safe scalar values or arrays.

Related Issue: https://github.com/WordPress/gutenberg/issues/73157

## Solution

Added a new preserve_valid_settings() method and SAFE_SETTINGS const that work to preserves valid settings.

## Testing Instructions

### Manual Testing

  1. Enable KSES filters:
    add_action( 'init', 'kses_init_filters' );
    

Add this to your theme's functions.php or a plugin.

  1. Test Image Block Lightbox Settings:
    • Go to Appearance > Editor > Styles
    • Navigate to Blocks > Image
    • Open the Settings panel
    • Toggle the "Enlarge on click" (lightbox) setting
    • Save the changes
    • Expected: The setting should persist after saving and page reload
    • Before fix: The setting would revert after saving
  1. Test Other Valid Settings:
    • Try changing other valid settings in Global Styles (e.g., layout settings, spacing settings)
    • Save and verify they persist
    • Expected: All valid settings should be preserved

Trac ticket: https://core.trac.wordpress.org/ticket/64280

#2 @ellatrix
7 weeks ago

@ramonopoly Was this introduced in trunk (6.9)?

#3 @ramonopoly
7 weeks ago

  • Milestone changed from Awaiting Review to 7.0

Was this introduced in trunk (6.9)

Are you asking which milestone this should be?

I've updated it to 7.0. The bug has been around for eons. See:

https://github.com/WordPress/gutenberg/pull/73452#issuecomment-3562566719

#4 @ellatrix
7 weeks ago

Oh, I see it's filed under trunk which I thought means that it's introduced in the current unreleased version.

#5 @ramonopoly
7 weeks ago

  • Version changed from trunk to 6.4

Oh, I see it's filed under trunk which I thought means that it's introduced in the current unreleased version.

Oh, that is a very good point.

I think the bug was introduced in 6.4!

https://github.com/WordPress/gutenberg/pull/54509

So the "version" is the affected version. https://make.wordpress.org/core/handbook/contribute/trac/

I get it. I can update.

Thanks for checking.

#6 @ellatrix
7 weeks ago

No worries. There's a lot of tickets filed wrongly under trunk I think, I just picked a random one to figure out why :)

Note: See TracTickets for help on using tickets.