Skip to:
Content

BuddyPress.org

Ticket #7795: 7795.3.patch

File 7795.3.patch, 13.9 KB (added by imath, 6 years ago)
  • src/bp-activity/bp-activity-filters.php

    diff --git src/bp-activity/bp-activity-filters.php src/bp-activity/bp-activity-filters.php
    index db71e25b1..189ef2599 100644
    function bp_activity_check_blacklist_keys( $activity ) { 
    202202 * @return string $content Filtered activity content.
    203203 */
    204204function bp_activity_filter_kses( $content ) {
    205         global $allowedtags;
    206 
    207         $activity_allowedtags = $allowedtags;
    208         $activity_allowedtags['a']['aria-label']      = array();
    209         $activity_allowedtags['a']['class']           = array();
    210         $activity_allowedtags['a']['data-bp-tooltip'] = array();
    211         $activity_allowedtags['a']['id']              = array();
    212         $activity_allowedtags['a']['rel']             = array();
    213         $activity_allowedtags['a']['title']           = array();
    214 
    215         $activity_allowedtags['b']    = array();
    216         $activity_allowedtags['code'] = array();
    217         $activity_allowedtags['i']    = array();
    218 
    219         $activity_allowedtags['img']           = array();
    220         $activity_allowedtags['img']['src']    = array();
    221         $activity_allowedtags['img']['alt']    = array();
    222         $activity_allowedtags['img']['width']  = array();
    223         $activity_allowedtags['img']['height'] = array();
    224         $activity_allowedtags['img']['class']  = array();
    225         $activity_allowedtags['img']['id']     = array();
    226 
    227         $activity_allowedtags['span']                   = array();
    228         $activity_allowedtags['span']['class']          = array();
    229         $activity_allowedtags['span']['data-livestamp'] = array();
    230 
    231         $activity_allowedtags['ul'] = array();
    232         $activity_allowedtags['ol'] = array();
    233         $activity_allowedtags['li'] = array();
    234 
    235205        /**
    236206         * Filters the allowed HTML tags for BuddyPress Activity content.
    237207         *
    function bp_activity_filter_kses( $content ) { 
    239209         *
    240210         * @param array $value Array of allowed HTML tags and attributes.
    241211         */
    242         $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
     212        $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', bp_get_allowedtags() );
    243213        return wp_kses( $content, $activity_allowedtags );
    244214}
    245215
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index 570d2b3b2..821a12205 100644
    function bp_email_get_unsubscribe_type_schema() { 
    38033803         */
    38043804        return (array) apply_filters( 'bp_email_get_unsubscribe_type_schema', $emails );
    38053805}
     3806
     3807/**
     3808 * Get BuddyPress content allowed tags.
     3809 *
     3810 * @since  3.0.0
     3811 *
     3812 * @global array $allowedtags KSES allowed HTML elements.
     3813 * @return array              BuddyPress content allowed tags.
     3814 */
     3815function bp_get_allowedtags() {
     3816        global $allowedtags;
     3817
     3818        return array_merge_recursive( $allowedtags, array(
     3819                'a' => array(
     3820                        'aria-label'      => array(),
     3821                        'class'           => array(),
     3822                        'data-bp-tooltip' => array(),
     3823                        'id'              => array(),
     3824                        'rel'             => array(),
     3825                ),
     3826                'img' => array(
     3827                        'src'    => array(),
     3828                        'alt'    => array(),
     3829                        'width'  => array(),
     3830                        'height' => array(),
     3831                        'class'  => array(),
     3832                        'id'     => array(),
     3833                ),
     3834                'span'=> array(
     3835                        'class'          => array(),
     3836                        'data-livestamp' => array(),
     3837                ),
     3838                'ul' => array(),
     3839                'ol' => array(),
     3840                'li' => array(),
     3841        ) );
     3842}
  • src/bp-messages/bp-messages-filters.php

    diff --git src/bp-messages/bp-messages-filters.php src/bp-messages/bp-messages-filters.php
    index 8b3404bc2..05ca3eee3 100644
    add_filter( 'bp_get_message_thread_subject', 'wp_filter_kses', 1 ); 
    1818add_filter( 'bp_get_message_thread_excerpt',        'wp_filter_kses', 1 );
    1919add_filter( 'bp_get_messages_subject_value',        'wp_filter_kses', 1 );
    2020add_filter( 'bp_get_messages_content_value',        'wp_filter_kses', 1 );
    21 add_filter( 'bp_get_the_thread_message_content',    'wp_filter_kses', 1 );
    22 
    23 add_filter( 'messages_message_content_before_save', 'wp_filter_kses', 1 );
    2421add_filter( 'messages_message_subject_before_save', 'wp_filter_kses', 1 );
    25 add_filter( 'messages_notice_message_before_save',  'wp_filter_kses', 1 );
    2622add_filter( 'messages_notice_subject_before_save',  'wp_filter_kses', 1 );
    27 
    28 add_filter( 'bp_get_the_thread_message_content',    'wp_filter_kses', 1 );
    2923add_filter( 'bp_get_the_thread_subject',            'wp_filter_kses', 1 );
    3024
     25add_filter( 'bp_get_the_thread_message_content',    'bp_messages_filter_kses', 1 );
     26add_filter( 'messages_message_content_before_save', 'bp_messages_filter_kses', 1 );
     27add_filter( 'messages_notice_message_before_save',  'bp_messages_filter_kses', 1 );
     28add_filter( 'bp_get_message_thread_content',        'bp_messages_filter_kses', 1 );
     29
    3130add_filter( 'messages_message_content_before_save', 'force_balance_tags' );
    3231add_filter( 'messages_message_subject_before_save', 'force_balance_tags' );
    3332add_filter( 'messages_notice_message_before_save',  'force_balance_tags' );
    add_filter( 'bp_get_message_notice_text', 'wptexturize' ); 
    4544add_filter( 'bp_get_message_thread_subject',     'wptexturize' );
    4645add_filter( 'bp_get_message_thread_excerpt',     'wptexturize' );
    4746add_filter( 'bp_get_the_thread_message_content', 'wptexturize' );
     47add_filter( 'bp_get_message_thread_content',     'wptexturize' );
    4848
    4949add_filter( 'bp_get_message_notice_subject',     'convert_smilies', 2 );
    5050add_filter( 'bp_get_message_notice_text',        'convert_smilies', 2 );
    5151add_filter( 'bp_get_message_thread_subject',     'convert_smilies', 2 );
    5252add_filter( 'bp_get_message_thread_excerpt',     'convert_smilies', 2 );
    5353add_filter( 'bp_get_the_thread_message_content', 'convert_smilies', 2 );
     54add_filter( 'bp_get_message_thread_content',     'convert_smilies', 2 );
    5455
    5556add_filter( 'bp_get_message_notice_subject',     'convert_chars' );
    5657add_filter( 'bp_get_message_notice_text',        'convert_chars' );
    5758add_filter( 'bp_get_message_thread_subject',     'convert_chars' );
    5859add_filter( 'bp_get_message_thread_excerpt',     'convert_chars' );
    5960add_filter( 'bp_get_the_thread_message_content', 'convert_chars' );
     61add_filter( 'bp_get_message_thread_content',     'convert_chars' );
    6062
    6163add_filter( 'bp_get_message_notice_text',        'make_clickable', 9 );
    6264add_filter( 'bp_get_the_thread_message_content', 'make_clickable', 9 );
     65add_filter( 'bp_get_message_thread_content',     'make_clickable', 9 );
    6366
    6467add_filter( 'bp_get_message_notice_text',        'wpautop' );
    6568add_filter( 'bp_get_the_thread_message_content', 'wpautop' );
     69add_filter( 'bp_get_message_thread_content',     'wpautop' );
    6670
    67 add_filter( 'bp_get_message_notice_subject',          'stripslashes_deep' );
    68 add_filter( 'bp_get_message_notice_text',             'stripslashes_deep' );
    69 add_filter( 'bp_get_message_thread_subject',          'stripslashes_deep' );
    70 add_filter( 'bp_get_message_thread_excerpt',          'stripslashes_deep' );
    71 add_filter( 'bp_get_message_get_recipient_usernames', 'stripslashes_deep' );
    72 add_filter( 'bp_get_messages_subject_value',          'stripslashes_deep' );
    73 add_filter( 'bp_get_messages_content_value',          'stripslashes_deep' );
    74 add_filter( 'bp_get_the_thread_message_content',      'stripslashes_deep' );
    75 add_filter( 'bp_get_the_thread_subject',              'stripslashes_deep' );
     71add_filter( 'bp_get_message_notice_subject',          'stripslashes_deep'    );
     72add_filter( 'bp_get_message_notice_text',             'stripslashes_deep'    );
     73add_filter( 'bp_get_message_thread_subject',          'stripslashes_deep'    );
     74add_filter( 'bp_get_message_thread_excerpt',          'stripslashes_deep'    );
     75add_filter( 'bp_get_message_get_recipient_usernames', 'stripslashes_deep'    );
     76add_filter( 'bp_get_messages_subject_value',          'stripslashes_deep'    );
     77add_filter( 'bp_get_messages_content_value',          'stripslashes_deep'    );
     78add_filter( 'bp_get_the_thread_message_content',      'stripslashes_deep'    );
     79add_filter( 'bp_get_the_thread_subject',              'stripslashes_deep'    );
     80add_filter( 'bp_get_message_thread_content',          'stripslashes_deep', 1 );
    7681
    7782/**
    7883 * Enforce limitations on viewing private message contents
    function bp_messages_enforce_current_user( $args = array() ) { 
    98103        return $args;
    99104}
    100105add_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_enforce_current_user', 5 );
     106
     107/**
     108 * Custom kses filtering for message content.
     109 *
     110 * @since 3.0.0
     111 *
     112 * @param string $content The message content.
     113 * @return string         The filtered message content.
     114 */
     115function bp_messages_filter_kses( $content ) {
     116        $messages_allowedtags      = bp_get_allowedtags();
     117        $messages_allowedtags['p'] = array();
     118
     119        /**
     120         * Filters the allowed HTML tags for BuddyPress Messages content.
     121         *
     122         * @since 3.0.0
     123         *
     124         * @param array $value Array of allowed HTML tags and attributes.
     125         */
     126        $messages_allowedtags = apply_filters( 'bp_messages_allowed_tags', $messages_allowedtags );
     127        return wp_kses( $content, $messages_allowedtags );
     128}
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php

    diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php
    index a5eade58f..5e877b442 100644
     
    4141
    4242<script type="text/html" id="tmpl-bp-messages-editor">
    4343        <?php
    44         // Temporarily filter the editor
    45         add_filter( 'mce_buttons', 'bp_nouveau_mce_buttons', 10, 1 );
     44        // Add a temporary filter on editor buttons
     45        add_filter( 'mce_buttons', 'bp_nouveau_messages_mce_buttons', 10, 1 );
    4646
    4747        wp_editor(
    4848                '',
     
    5858                        'textarea_rows' => 5,
    5959                )
    6060        );
    61         // Temporarily filter the editor
    62         remove_filter( 'mce_buttons', 'bp_nouveau_mce_buttons', 10, 1 );
     61        // Remove the temporary filter on editor buttons
     62        remove_filter( 'mce_buttons', 'bp_nouveau_messages_mce_buttons', 10, 1 );
    6363        ?>
    6464</script>
    6565
  • src/bp-templates/bp-nouveau/css/buddypress-rtl.css

    diff --git src/bp-templates/bp-nouveau/css/buddypress-rtl.css src/bp-templates/bp-nouveau/css/buddypress-rtl.css
    index 8ca16031f..1c867a215 100644
    body.register .buddypress-wrap .page ul { 
    30643064}
    30653065
    30663066.bp-messages-content #thread-preview .preview-message {
    3067         clear: both;
     3067        overflow: hidden;
    30683068}
    30693069
    30703070.bp-messages-content #thread-preview .preview-content {
    body.register .buddypress-wrap .page ul { 
    31333133}
    31343134
    31353135.bp-messages-content #bp-message-thread-list .message-content {
    3136         clear: both;
     3136        overflow: hidden;
    31373137        margin: 1em auto 0;
    31383138        width: 90%;
    31393139}
  • src/bp-templates/bp-nouveau/css/buddypress.css

    diff --git src/bp-templates/bp-nouveau/css/buddypress.css src/bp-templates/bp-nouveau/css/buddypress.css
    index 937c37a67..06ea3d37e 100644
    body.register .buddypress-wrap .page ul { 
    30643064}
    30653065
    30663066.bp-messages-content #thread-preview .preview-message {
    3067         clear: both;
     3067        overflow: hidden;
    30683068}
    30693069
    30703070.bp-messages-content #thread-preview .preview-content {
    body.register .buddypress-wrap .page ul { 
    31333133}
    31343134
    31353135.bp-messages-content #bp-message-thread-list .message-content {
    3136         clear: both;
     3136        overflow: hidden;
    31373137        margin: 1em auto 0;
    31383138        width: 90%;
    31393139}
  • src/bp-templates/bp-nouveau/includes/messages/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php
    index 852637084..5eebdc077 100644
    function bp_nouveau_push_sitewide_notices() { 
    299299}
    300300
    301301/**
     302 * Disable the WP Editor buttons not allowed in messages content.
     303 *
    302304 * @since 3.0.0
     305 *
     306 * @param array $buttons The WP Editor buttons list.
     307 * @param array          The filtered WP Editor buttons list.
    303308 */
    304 function bp_nouveau_mce_buttons( $buttons = array() ) {
     309function bp_nouveau_messages_mce_buttons( $buttons = array() ) {
    305310        $remove_buttons = array(
    306311                'wp_more',
    307312                'spellchecker',
    308313                'wp_adv',
    309314                'fullscreen',
     315                'alignleft',
     316                'alignright',
     317                'aligncenter',
     318                'formatselect',
    310319        );
    311320
    312321        // Remove unused buttons
  • src/bp-templates/bp-nouveau/includes/messages/loader.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/loader.php src/bp-templates/bp-nouveau/includes/messages/loader.php
    index f979c5630..3f83163f3 100644
    class BP_Nouveau_Messages { 
    102102
    103103                // Messages
    104104                add_filter( 'bp_messages_admin_nav', 'bp_nouveau_messages_adjust_admin_nav', 10, 1 );
    105 
    106                 remove_filter( 'messages_notice_message_before_save', 'wp_filter_kses', 1 );
    107                 remove_filter( 'messages_message_content_before_save', 'wp_filter_kses', 1 );
    108                 remove_filter( 'bp_get_the_thread_message_content', 'wp_filter_kses', 1 );
    109 
    110                 add_filter( 'messages_notice_message_before_save', 'wp_filter_post_kses', 1 );
    111                 add_filter( 'messages_message_content_before_save', 'wp_filter_post_kses', 1 );
    112                 add_filter( 'bp_get_the_thread_message_content', 'wp_filter_post_kses', 1 );
    113                 add_filter( 'bp_get_message_thread_content', 'wp_filter_post_kses', 1 );
    114                 add_filter( 'bp_get_message_thread_content', 'wptexturize' );
    115                 add_filter( 'bp_get_message_thread_content', 'stripslashes_deep', 1 );
    116                 add_filter( 'bp_get_message_thread_content', 'convert_smilies', 2 );
    117                 add_filter( 'bp_get_message_thread_content', 'convert_chars' );
    118                 add_filter( 'bp_get_message_thread_content', 'make_clickable', 9 );
    119                 add_filter( 'bp_get_message_thread_content', 'wpautop' );
    120105        }
    121106}
    122107
  • src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss

    diff --git src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss
    index 89747071c..a9a44a599 100644
     
    192192                margin-top: $marg-lrg;
    193193
    194194                .preview-message {
    195                         clear: both;
     195                        overflow: hidden;
    196196                }
    197197
    198198                .preview-content {
     
    263263                }
    264264
    265265                .message-content {
    266                         clear: both;
     266                        overflow: hidden;
    267267                        margin: 1em auto 0;
    268268                        width: 90%;
    269269                }