-
-
Notifications
You must be signed in to change notification settings - Fork 113
Minor fixes and updates #542
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: master
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -91,6 +91,9 @@ private function set_lcp_parameters(){ | |||||||||||||||||
// http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/post.php#L1686 | ||||||||||||||||||
$args['posts_per_page'] = $args['numberposts']; | ||||||||||||||||||
|
||||||||||||||||||
if (isset($args['post_status'])){ | ||||||||||||||||||
$args['post_status'] = $this->sanitize_status($args['post_status']); | ||||||||||||||||||
} | ||||||||||||||||||
do_action( 'lcp_pre_run_query', $args ); | ||||||||||||||||||
|
||||||||||||||||||
if ('no' === $this->params['main_query']) { | ||||||||||||||||||
|
@@ -444,16 +447,23 @@ public function get_content($single) { | |||||||||||||||||
if (isset($this->params['content']) && | ||||||||||||||||||
($this->params['content'] =='yes' || $this->params['content'] == 'full') && | ||||||||||||||||||
$single->post_content){ | ||||||||||||||||||
// get_extended - get content split by <!--more--> | ||||||||||||||||||
$lcp_extended = get_extended($single->post_content); | ||||||||||||||||||
$lcp_content = $lcp_extended['main']; | ||||||||||||||||||
$lcp_content = apply_filters('the_content', $lcp_content); | ||||||||||||||||||
$lcp_content = str_replace(']]>', ']]>', $lcp_content); | ||||||||||||||||||
// If the post is password protected, set the password form in the content. | ||||||||||||||||||
if (post_password_required($single)) { | ||||||||||||||||||
$lcp_content = get_the_password_form($single); | ||||||||||||||||||
return $lcp_content; | ||||||||||||||||||
} else { | ||||||||||||||||||
// get_extended - get content split by <!--more--> | ||||||||||||||||||
$lcp_extended = get_extended($single->post_content); | ||||||||||||||||||
$lcp_content = $lcp_extended['main']; | ||||||||||||||||||
$lcp_content = apply_filters('the_content', $lcp_content); | ||||||||||||||||||
$lcp_content = str_replace(']]>', ']]>', $lcp_content); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if ($this->params['content'] == 'full') { | ||||||||||||||||||
$lcp_extended_content = str_replace( | ||||||||||||||||||
']]>', | ||||||||||||||||||
']]>', apply_filters('the_content', $lcp_extended['extended']) | ||||||||||||||||||
']]>', | ||||||||||||||||||
apply_filters('the_content', $lcp_extended['extended']) | ||||||||||||||||||
); | ||||||||||||||||||
$lcp_content .= $lcp_extended_content; | ||||||||||||||||||
} else { | ||||||||||||||||||
|
@@ -468,7 +478,7 @@ public function get_content($single) { | |||||||||||||||||
} | ||||||||||||||||||
return $lcp_content; | ||||||||||||||||||
} else { | ||||||||||||||||||
return null; | ||||||||||||||||||
return null; | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -598,4 +608,18 @@ public function get_pagination() { | |||||||||||||||||
); | ||||||||||||||||||
return LcpPaginator::get_instance()->get_pagination($paginator_params); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// Sanitizes the statuses for post_status. Checks if current user is either editor or | ||||||||||||||||||
// admininstrator. Other users can't see draft or private posts. | ||||||||||||||||||
private function sanitize_status($statuses){ | ||||||||||||||||||
if (in_array('private', $statuses) || in_array('draft', $statuses)) { | ||||||||||||||||||
if ( !( current_user_can('editor') || current_user_can('administrator')) ) { | ||||||||||||||||||
$private_index = array_search('private', $statuses); | ||||||||||||||||||
unset($statuses[$private_index]); | ||||||||||||||||||
$draft_index = array_search('draft', $statuses); | ||||||||||||||||||
unset($statuses[$draft_index]); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
return implode(',', $statuses); | ||||||||||||||||||
Comment on lines
+614
to
+623
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. When private function sanitize_status($statuses){
if (in_array('private', $statuses) || in_array('draft', $statuses)) {
if ( !( current_user_can('editor') || current_user_can('administrator')) ) {
$private_index = array_search('private', $statuses);
if ($private_index !== false) {
unset($statuses[$private_index]);
}
$draft_index = array_search('draft', $statuses);
if ($draft_index !== false) {
unset($statuses[$draft_index]);
}
}
}
return implode(',', $statuses); 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. Is the vulnerability anly about Another problem is this section of lcp-parameters.php: List-Category-Posts/include/lcp-parameters.php Lines 78 to 85 in b7a52be
No need to delete it but maybe just add a check if a user is Editor or Administrator. |
||||||||||||||||||
} | ||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@klemens-st I think it's ok to just return the content here, without the filters and replace we do in the
else
branch. Sinceget_the_password_form
applies its own filters. The goal is not to show the content unless you've submitted the right password.From my tests, if you input the right password, WordPress redirects you to the page and if you go back to where the posts are listed, it does show the content (if
content=yes
andshow_protected=yes
are set).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works nicely and yes the
get_the_password_form
function seems to return display ready HTML and doesn't need further filters.