Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54296 closed defect (bug) (fixed)

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

Reported by: amustaque97's profile amustaque97 Owned by: audrasjb's profile 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.


3 years ago
#1

  • 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.


3 years ago
#2

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
3 years 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.


3 years ago

#5 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 5.9

#6 @hellofromTonya
3 years ago

  • Keywords commit added

Marking PR 1777 for commit.

#7 @audrasjb
3 years ago

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

Self assigning for final review then commit.

#9 @audrasjb
3 years 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.