Make WordPress Core

Opened 21 hours ago

Last modified 21 hours ago

#63633 new defect (bug)

Post Types with numeric characters in the slug are not searchable within the nav menu

Reported by: kshaner's profile kshaner Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 6.8
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

When a post type is registered, the slug is run through sanitize_key.

The docblock for sanitize_key:

Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes, and underscores are allowed.

When a post type is registered with a numeric character, the function _wp_ajax_menu_quick_search contains a regex that tries to match the post type from the request payload $_POSTtype? which contains a payload formatted like: quick-search-posttype-post or quick-search-posttype-page.

However when a numeric character is in the post type slug, the regex that validates the post type does not allow numeric characters.

The current call is:

preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) )

To match the allowed formats of sanitize_key, this regex should be modified to:

preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z0-9_-]*\b)/', $type, $matches ) )

Change History (1)

Note: See TracTickets for help on using tickets.
OSZAR »