diff --git src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
index b89b56c..5317c94 100644
|
|
class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { |
639 | 639 | $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] ); |
640 | 640 | |
641 | 641 | // Apply the same filters as when calling wp_insert_post(). |
642 | | $menu_item_value['title'] = apply_filters( 'title_save_pre', $menu_item_value['title'] ); |
643 | | $menu_item_value['attr_title'] = apply_filters( 'excerpt_save_pre', $menu_item_value['attr_title'] ); |
644 | | $menu_item_value['description'] = apply_filters( 'content_save_pre', $menu_item_value['description'] ); |
| 642 | $menu_item_value['title'] = wp_unslash( apply_filters( 'title_save_pre', wp_slash( $menu_item_value['title'] ) ) ); |
| 643 | $menu_item_value['attr_title'] = wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $menu_item_value['attr_title'] ) ) ); |
| 644 | $menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) ); |
645 | 645 | |
646 | 646 | $menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] ); |
647 | 647 | if ( 'publish' !== $menu_item_value['status'] ) { |
… |
… |
class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { |
776 | 776 | $r = wp_update_nav_menu_item( |
777 | 777 | $value['nav_menu_term_id'], |
778 | 778 | $is_placeholder ? 0 : $this->post_id, |
779 | | $menu_item_data |
| 779 | wp_slash( $menu_item_data ) |
780 | 780 | ); |
781 | 781 | |
782 | 782 | if ( is_wp_error( $r ) ) { |
diff --git src/wp-includes/nav-menu.php src/wp-includes/nav-menu.php
index 9ab6786..3b878f7 100644
|
|
function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { |
344 | 344 | /** |
345 | 345 | * Save the properties of a menu item or create a new one. |
346 | 346 | * |
| 347 | * The menu-item-title, menu-item-description, and menu-item-attr-title are expected |
| 348 | * to be pre-slashed since they are passed directly into <code>wp_insert_post()</code>. |
| 349 | * |
347 | 350 | * @since 3.0.0 |
348 | 351 | * |
349 | 352 | * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan. |
diff --git tests/phpunit/tests/customize/nav-menu-item-setting.php tests/phpunit/tests/customize/nav-menu-item-setting.php
index 3431ef8..e06db56 100644
|
|
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
450 | 450 | 'menu_item_parent' => 'asdasd', |
451 | 451 | 'position' => -123, |
452 | 452 | 'type' => 'custom<b>', |
453 | | 'title' => 'Hi<script>unfilteredHtml()</script>', |
| 453 | 'title' => '\o/ o\'o Hi<script>unfilteredHtml()</script>', |
454 | 454 | 'url' => 'javascript:alert(1)', |
455 | 455 | 'target' => '" onclick="', |
456 | | 'attr_title' => '<b>bolded</b><script>unfilteredHtml()</script>', |
457 | | 'description' => '<b>Hello world</b><script>unfilteredHtml()</script>', |
| 456 | 'attr_title' => '\o/ o\'o <b>bolded</b><script>unfilteredHtml()</script>', |
| 457 | 'description' => '\o/ o\'o <b>Hello world</b><script>unfilteredHtml()</script>', |
458 | 458 | 'classes' => 'hello " inject="', |
459 | 459 | 'xfn' => 'hello " inject="', |
460 | 460 | 'status' => 'forbidden', |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
469 | 469 | 'menu_item_parent' => 0, |
470 | 470 | 'position' => -123, |
471 | 471 | 'type' => 'customb', |
472 | | 'title' => current_user_can( 'unfiltered_html' ) ? 'Hi<script>unfilteredHtml()</script>' : 'HiunfilteredHtml()', |
| 472 | 'title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o Hi<script>unfilteredHtml()</script>' : '\o/ o\'o HiunfilteredHtml()', |
473 | 473 | 'url' => '', |
474 | 474 | 'target' => 'onclick', |
475 | | 'attr_title' => current_user_can( 'unfiltered_html' ) ? '<b>bolded</b><script>unfilteredHtml()</script>' : '<b>bolded</b>unfilteredHtml()', |
476 | | 'description' => current_user_can( 'unfiltered_html' ) ? '<b>Hello world</b><script>unfilteredHtml()</script>' : '<b>Hello world</b>unfilteredHtml()', |
| 475 | 'attr_title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>bolded</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>bolded</b>unfilteredHtml()', |
| 476 | 'description' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>Hello world</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>Hello world</b>unfilteredHtml()', |
477 | 477 | 'classes' => 'hello inject', |
478 | 478 | 'xfn' => 'hello inject', |
479 | 479 | 'status' => 'draft', |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
488 | 488 | $this->assertEquals( $value, $sanitized[ $key ], "Expected $key to be sanitized." ); |
489 | 489 | } |
490 | 490 | |
491 | | $nav_menu_item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
| 491 | $nav_menu_item_id = wp_update_nav_menu_item( $menu_id, 0, wp_slash( array( |
492 | 492 | 'menu-item-object-id' => $unsanitized['object_id'], |
493 | 493 | 'menu-item-object' => $unsanitized['object'], |
494 | 494 | 'menu-item-parent-id' => $unsanitized['menu_item_parent'], |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
502 | 502 | 'menu-item-classes' => $unsanitized['classes'], |
503 | 503 | 'menu-item-xfn' => $unsanitized['xfn'], |
504 | 504 | 'menu-item-status' => $unsanitized['status'], |
505 | | ) ); |
| 505 | ) ) ); |
506 | 506 | |
507 | 507 | $post = get_post( $nav_menu_item_id ); |
508 | 508 | $nav_menu_item = wp_setup_nav_menu_item( clone $post ); |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
549 | 549 | 'type' => 'post_type', |
550 | 550 | 'object' => 'post', |
551 | 551 | 'object_id' => $second_post_id, |
552 | | 'title' => 'Saludos', |
| 552 | 'title' => 'Saludos \o/', |
553 | 553 | 'status' => 'publish', |
554 | 554 | 'nav_menu_term_id' => $secondary_menu_id, |
555 | 555 | ); |