WordPress.org

Make WordPress Core

Opened 7 weeks ago

Closed 10 days ago

Last modified 10 days ago

#54296 closed defect (bug) (fixed)

Make sure the name does not contain spacing before creating the class

Reported by: amustaque97 Owned by: audrasjb
Milestone: 5.9 Priority: normal
Severity: minor Version:
Component: Editor Keywords: has-patch has-unit-tests commit
Focuses: css Cc:

Description

This was reported in https://wordpress.slack.com/archives/C02QB2JS7/p1629731076397000.

The process of generating a class for a style variation is not checking for spaces.

Step-by-step reproduction instructions

Add a style variation such as (note the spacing in the name):

<?php
register_block_style( $block, array(
        'label'                         => esc_html__( 'Style Name', 'slug' ),
        'name'                          => 'style-class-1 style-class-2'
) );

When this style variation is selected by the user the CSS class attached to the block is

is-style-class-1 style-class-2

register_block_style function should return an error it doesn't contain spaces.

Change History (11)

This ticket was mentioned in PR #1777 on WordPress/wordpress-develop by amustaque97.


6 weeks ago

  • Keywords has-patch has-unit-tests added

Fixes #54296(trac issue, given link down below) originally it was reported in the Gutenberg repo issue #34242
In this commit, I have added a check inside the function if block style name
contain space it will trigger a notice and return false.

I have added a test case as well for this scenario

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

This ticket was mentioned in PR #1777 on WordPress/wordpress-develop by amustaque97.


6 weeks ago

Fixes #54296(trac issue, given link down below) originally it was reported in the Gutenberg repo issue #34242
In this commit, I have added a check inside the function if block style name
contain space it will trigger a notice and return false.

I have added a test case as well for this scenario

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

#3 @amustaque97
6 weeks ago

PR is reviewed by @costdev. I have addressed review comments.

This ticket was mentioned in Slack in #core-editor by amustaque97. View the logs.


6 weeks ago

#5 @SergeyBiryukov
2 weeks ago

  • Milestone changed from Awaiting Review to 5.9

#6 @hellofromTonya
2 weeks ago

  • Keywords commit added

Marking PR 1777 for commit.

#7 @audrasjb
10 days ago

  • Owner changed from amustaque97 to audrasjb
  • Status changed from assigned to reviewing

Self assigning for final review then commit.

#9 @audrasjb
10 days ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 52261:

Editor: Ensure block style name does not contain spaces before creating the class.

This change adds a check to ensure there is no spaces in block style variation names before generating the class. Returns false and a _doing_it_wrong() message if a space is detected.

Props amustaque97, costdev, hellofromtonya, pbiron, SergeyBiryukov, afragen.
Fixes #54296.

Note: See TracTickets for help on using tickets.