-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Query: Add is_scalar validation for attachment and post type query vars #11650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 3 commits
1641032
1eff3fb
5474cfa
6ad3fbf
8c282c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -878,6 +878,10 @@ public function parse_query( $query = '' ) { | |
|
|
||
| $query_vars['attachment_id'] = is_scalar( $query_vars['attachment_id'] ) ? absint( $query_vars['attachment_id'] ) : 0; | ||
|
|
||
| if ( ! is_scalar( $query_vars['attachment'] ) ) { | ||
| $query_vars['attachment'] = ''; | ||
| } | ||
|
|
||
| if ( ( '' !== $query_vars['attachment'] ) || ! empty( $query_vars['attachment_id'] ) ) { | ||
| $this->is_single = true; | ||
| $this->is_attachment = true; | ||
|
|
@@ -2152,11 +2156,17 @@ public function get_posts() { | |
|
|
||
| if ( ! $ptype_obj->hierarchical ) { | ||
| // Non-hierarchical post types can directly use 'name'. | ||
| $query_vars['name'] = $query_vars[ $ptype_obj->query_var ]; | ||
| if ( is_scalar( $query_vars[ $ptype_obj->query_var ] ) ) { | ||
| $query_vars['name'] = $query_vars[ $ptype_obj->query_var ]; | ||
| } else { | ||
| $query_vars['name'] = ''; | ||
| } | ||
| } else { | ||
| // Hierarchical post types will operate through 'pagename'. | ||
| $query_vars['pagename'] = $query_vars[ $ptype_obj->query_var ]; | ||
| $query_vars['name'] = ''; | ||
| if ( is_scalar( $query_vars[ $ptype_obj->query_var ] ) ) { | ||
| $query_vars['pagename'] = $query_vars[ $ptype_obj->query_var ]; | ||
| } | ||
| $query_vars['name'] = ''; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this only empty out the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name should be emptied since hierarchical post types operate exclusively through |
||
| } | ||
|
|
||
| // Only one request for a slug is possible, this is why name & pagename are overwritten above. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.