#57110 closed defect (bug) (fixed)
Correctly some attributes escape is missing in this ( wp-admin/includes/nav-menu.php ) file.
| Reported by: | zenaulislam | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.3 |
| Component: | Menus | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | administration, coding-standards |
Description
I found some missing escape attributes inside this file 'wp-admin/includes/nav-menu.php'
I think we can improve it by escaping the attributes for more consistency.
Change History (10)
This ticket was mentioned in PR #3626 on WordPress/wordpress-develop by @zenaulislam.
4 years ago
#1
#3
@
4 years ago
Hello @SergeyBiryukov,
Thank you so much.
PR request has been switched from the master to the trunk.
#5
follow-up:
↓ 7
@
4 years ago
- Component Administration → Menus
- Focuses administration added
- Milestone Awaiting Review → 6.3
Thanks for the PR! It looks good, I only have two minor notes:
- It would be more consistent with some existing instances to only escape the variable, e.g.
<div id="posttype-<?php echo esc_attr( $post_type_name ); ?>" class="posttypediv">
instead of:<div id="<?php echo esc_attr( 'posttype-' . $post_type_name ); ?>" class="posttypediv">
- We should also escape
$taxonomy_nameinwp_nav_menu_item_taxonomy_meta_box()in a similar way.
This can be addressed on commit.
#7
in reply to: ↑ 5
@
4 years ago
- Resolution fixed
- Status closed → reopened
Replying to SergeyBiryukov:
It would be more consistent with some existing instances to only escape the variable, e.g.
<div id="posttype-<?php echo esc_attr( $post_type_name ); ?>" class="posttypediv">instead of:
<div id="<?php echo esc_attr( 'posttype-' . $post_type_name ); ?>" class="posttypediv">
Ah, it looks like I missed Juliette's comment here that the latter is actually best practice:
Here and in other places: it is best to always escape the complete value of an attribute, not a partial value, as otherwise the escaping could be (partially) undone when the values are joined together.
While the hard-coded prefix/suffix values in this case don't necessarily create that risk, those may change to values which could be problematic, so making it a habit to escape the value in one go is best practice.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: (https://core.trac.wordpress.org/ticket/57110)