WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 months ago

Last modified 2 months ago

#17409 closed defect (bug) (invalid)

Entity & in menu title breaks XHTML 1.0 Strict validation

Reported by: Florat Owned by: Florian
Milestone: Priority: normal
Severity: normal Version: 3.1.2
Component: Menus Keywords:
Focuses: Cc:

Description

If i use & in the menu title and use $my_menu = wp_get_nav_menu_items("my_menu") and loop with foreach($my_menu as $menu_item) and connect for building the Menu on $menu_item->title, then an & in the page title or on the menu navigation label is convertet to a simple &, witch returns the validation error "xmlParseEntityRef: no name".

Change History (4)

comment:1 ircbot2 months ago

This ticket was mentioned in IRC in #wordpress-dev by Steve_p. View the logs.

comment:2 ocean902 months ago

  • Keywords xmlParseEntityRef wp_get_nav_menu_items removed

comment:3 follow-up: Steve_p2 months ago

  • Keywords close added
  • Resolution set to invalid
  • Status changed from new to closed

Thanks for the report and sorry for taking so long to get back to you. This does not seem to be a bug. When using $menu_item->menu_title directly, you need to use esc_html() to encode HTML entities correctly.

comment:4 in reply to: ↑ 3 ocean902 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted

Replying to Steve_p:

When using $menu_item->menu_title directly, you need to use esc_html() to encode HTML entities correctly.

Or, as wp_nav_menu() and his Walker, do apply_filters( 'the_title', $menu_item->menu_title, $menu_item->ID ).

Note: See TracTickets for help on using tickets.