Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16113 closed defect (bug) (duplicate)

Appearance->Menu panel's module's search function doesn't see posts/pages with newlines in content

Reported by: alxndr's profile alxndr Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.4
Component: Menus Keywords: menus newline, sanitizing, htmlattributes
Focuses: Cc:


In the Menus feature introduced in WP3, the Search function in the Posts and Pages modules apparently cannot handle posts which have multiple lines of content.

The search feature sends out a string to search for to /wp-admin/admin-ajax.php, which sends back a bunch of <li> elements (one per post/page found), each containing a bunch of <input> elements (for post/page ID, title, etc). One of the hidden <input>s is the full content of the post/page, and it does not sanitize newlines in any way. This apparently breaks whatever takes the <li>s from admin-ajax.php and sticks them into the results <ul> in those modules. I think I've confirmed this by modifying line 252 in /wp-admin/includes/nav-menu.php (the hidden <input> with the full content, class="menu-item-description"); changing this:

$output .= '<input type="hidden" class="menu-item-description" name="menu-item[' . $possible_object_id . '][menu-item-description]" value="'. esc_attr( $item->description ) .'" />';

to this:

$output .= '<input type="hidden" class="menu-item-description" name="menu-item[' . $possible_object_id . '][menu-item-description]" value="'. str_replace(array("\n","\r"),'',esc_attr( $item->description )) .'" />';

...thus removing any CRs and LFs from the attribute. After that, search feature shows posts with multiple lines of content and allows them to be added to a menu.

Change History (5)

#1 @ocean90
13 years ago

Can you test it with 3.1 RC2 please? There was a change, maybe it's fixed already.

#2 @nacin
13 years ago

The change is that we're no longer sending menu-item-description. It unnecessarily bloated the page.

So this should be fixed.

#4 @alxndr
13 years ago


Loving the menus feature by the way. It's completely replacing my shoddily-slapped-together way of letting editors control what's in navigation menus.

#5 @scribu
13 years ago

  • Keywords changed from menus, newline, sanitizing, htmlattributes to menus newline, sanitizing, htmlattributes
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I remember fixing this by returning a JSON response, instead of straight HTML, but I can't find the ticket.

Anyway it's fixed.

Note: See TracTickets for help on using tickets.