[wp-trac] [WordPress Trac] #36590: POST['nav-menu-data'] breaks other POST values

WordPress Trac noreply at wordpress.org
Wed Apr 20 15:06:39 UTC 2016


#36590: POST['nav-menu-data'] breaks other POST values
-------------------------------------+-------------------------------------
 Reporter:  Unyson                   |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.5.1
Component:  Menus                    |     Version:  4.5
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch needs-       |     Focuses:  javascript,
  testing                            |  administration
-------------------------------------+-------------------------------------

Comment (by ericlewis):

 Replying to [comment:4 swissspidy]:
 > How can I reproduce it without using this plugin?

 Open an Edit Nav Menu screen with at least one item.

 Run this JavaScript

 {{{
 var inputCheckbox = jQuery('<input type="checkbox" name="somevariable[1
 ][title-off]">');
 jQuery('.menu-item .menu-item-settings').first().prepend(inputCheckbox);
 }}}

 which injects an input with a multidimensional name into the form.

 Submit the form, and inspect $_POST after the nav-menu-data expansion.
 Notice

 `["somevariable"]=> array(1) { [1]=> string(2) "on" }`

 where we would expect

 `["somevariable"]=> array(1) { [1]=> array(1) { [title-off] => string(2)
 "on" } }`

 This problem isn't expressed in core because
 [https://github.com/WordPress/WordPress/blob/4.5/wp-admin/includes/class-
 walker-nav-menu-edit.php the default Edit Nav Menu walker class] uses
 single-dimension arrays for input element names. However, plugins can
 supply their own Nav Menu Walker class, which can create any input element
 names.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36590#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list