Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/08/2017 04:46:28 PM (10 years ago)
Author:
boonebgorges
Message:

Improved nonce protection for some front-end AJAX endpoints.

Merge of [11449] to the 2.8 branch.

Location:
branches/2.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.8

  • branches/2.8/src/bp-templates/bp-legacy/buddypress-functions.php

    r11439 r11450  
    874874                case 'mentions':
    875875                        $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    876                         bp_activity_clear_new_mentions( bp_loggedin_user_id() );
     876
     877                        if ( isset( $_POST['_wpnonce_activity_filter'] ) && wp_verify_nonce( wp_unslash( $_POST['_wpnonce_activity_filter'] ), 'activity_filter' ) ) {
     878                                bp_activity_clear_new_mentions( bp_loggedin_user_id() );
     879                        }
     880
    877881                        break;
    878882                default:
    … …  
    11951199                return;
    11961200
     1201        if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'mark_favorite' ) ) {
     1202                return;
     1203        }
     1204
    11971205        if ( bp_activity_add_user_favorite( $_POST['id'] ) )
    11981206                _e( 'Remove Favorite', 'buddypress' );
    … …  
    12141222        if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    12151223                return;
     1224
     1225        if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'unmark_favorite' ) ) {
     1226                return;
     1227        }
    12161228
    12171229        if ( bp_activity_remove_user_favorite( $_POST['id'] ) )
    … …  
    15241536                return;
    15251537
    1526         if ( ! isset( $_POST['notice_id'] ) ) {
     1538        $nonce_check = isset( $_POST['nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'bp_messages_close_notice' );
     1539
     1540        if ( ! $nonce_check || ! isset( $_POST['notice_id'] ) ) {
    15271541                echo "-1<div id='message' class='error'><p>" . __( 'There was a problem closing the notice.', 'buddypress' ) . '</p></div>';
    15281542
    … …  
    16011615 * Mark a private message as unread in your inbox via a POST request.
    16021616 *
     1617 * No longer used.
     1618 *
    16031619 * @since 1.2.0
     1620 * @deprecated 2.2.0
    16041621 *
    16051622 * @return mixed String on error, void on success.
    16061623 */
    16071624function bp_legacy_theme_ajax_message_markunread() {
    1608         // Bail if not a POST action.
    1609         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    1610                 return;
    1611 
    1612         if ( ! isset($_POST['thread_ids']) ) {
    1613                 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem marking messages as unread.', 'buddypress' ) . '</p></div>';
    1614 
    1615         } else {
    1616                 $thread_ids = explode( ',', $_POST['thread_ids'] );
    1617 
    1618                 for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
    1619                         BP_Messages_Thread::mark_as_unread( (int) $thread_ids[$i] );
    1620                 }
    1621         }
    1622 
    1623         exit;
     1625        die( '-1' );
    16241626}
    16251627
    … …  
    16271629 * Mark a private message as read in your inbox via a POST request.
    16281630 *
     1631 * No longer used.
     1632 *
    16291633 * @since 1.2.0
     1634 * @deprecated 2.2.0
    16301635 *
    16311636 * @return mixed String on error, void on success.
    16321637 */
    16331638function bp_legacy_theme_ajax_message_markread() {
    1634         // Bail if not a POST action.
    1635         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    1636                 return;
    1637 
    1638         if ( ! isset($_POST['thread_ids']) ) {
    1639                 echo "-1<div id='message' class='error'><p>" . __('There was a problem marking messages as read.', 'buddypress' ) . '</p></div>';
    1640 
    1641         } else {
    1642                 $thread_ids = explode( ',', $_POST['thread_ids'] );
    1643 
    1644                 for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
    1645                         BP_Messages_Thread::mark_as_read( (int) $thread_ids[$i] );
    1646                 }
    1647         }
    1648 
    1649         exit;
     1639        die( '-1' );
    16501640}
    16511641
    … …  
    16531643 * Delete a private message(s) in your inbox via a POST request.
    16541644 *
     1645 * No longer used.
     1646 *
    16551647 * @since 1.2.0
     1648 * @deprecated 2.2.0
    16561649 *
    16571650 * @return string HTML
    16581651 */
    16591652function bp_legacy_theme_ajax_messages_delete() {
    1660         // Bail if not a POST action.
    1661         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    1662                 return;
    1663 
    1664         if ( ! isset($_POST['thread_ids']) ) {
    1665                 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem deleting messages.', 'buddypress' ) . '</p></div>';
    1666 
    1667         } else {
    1668                 $thread_ids = wp_parse_id_list( $_POST['thread_ids'] );
    1669                 messages_delete_thread( $thread_ids );
    1670 
    1671                 _e( 'Messages deleted.', 'buddypress' );
    1672         }
    1673 
    1674         exit;
     1653        die( '-1' );
    16751654}
    16761655
Note: See TracChangeset for help on using the changeset viewer.