Make WordPress Core

Changeset 47648

Timestamp:
04/29/2020 04:15:39 PM (4 years ago)
Author:
whyisjake
Message:

Customize: Add additional filters to Customizer to prevent JSON corruption.
User: Invalidate user_activation_key on password update.
Query: Ensure that only a single post can be returned on date/time based queries.
Cache API: Ensure proper escaping around the stats method in the cache API.
Formatting: Expand sanitize_file_name to have better support for utf8 characters.

Brings the changes in [47633], [47634], [47635], [47637], and [47638] to the 4.9 branch.

Props: batmoo, ehti, nickdaugherty, peterwilsoncc, sergeybiryukov, sstoqnov, westi, westonruter, whyisjake, whyisjake, xknown.

Location:
branches/4.9
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/cache.php

    r41688 r47648  
    669669        echo '<ul>';
    670670        foreach ($this->cache as $group => $cache) {
    671             echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
     671            echo . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
    672672        }
    673673        echo '</ul>';
  • branches/4.9/src/wp-includes/class-wp-customize-manager.php

    r43707 r47648  
    28602860        add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 5, 3 );
    28612861
    2862         // Update the changeset post. The publish_customize_changeset action will cause the settings in the changeset to be saved via WP_Customize_Setting::save().
    2863         $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) );
    2864         if ( $has_kses ) {
    2865             kses_remove_filters(); // Prevent KSES from corrupting JSON in post_content.
    2866         }
    2867 
    2868         // Note that updating a post with publish status will trigger WP_Customize_Manager::publish_changeset_values().
     2862        /*
     2863         * Update the changeset post. The publish_customize_changeset action will cause the settings in the
     2864         * changeset to be saved via WP_Customize_Setting::save(). Updating a post with publish status will
     2865         * trigger WP_Customize_Manager::publish_changeset_values().
     2866         */
     2867        add_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5, 3 );
    28692868        if ( $changeset_post_id ) {
    28702869            if ( $args['autosave'] && 'auto-draft' !== get_post_status( $changeset_post_id ) ) {
     
    28932892            }
    28942893        }
    2895         if ( $has_kses ) {
    2896             kses_init_filters();
    2897         }
     2894
     2895        );
     2896
    28982897        $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents.
    28992898
     
    29102909
    29112910        return $response;
     2911
     2912
     2913
     2914
     2915
     2916
     2917
     2918
     2919
     2920
     2921
     2922
     2923
     2924
     2925
     2926
     2927
     2928
     2929
     2930
     2931
     2932
     2933
     2934
     2935
     2936
     2937
     2938
     2939
     2940
     2941
     2942
     2943
     2944
     2945
     2946
     2947
     2948
     2949
     2950
     2951
     2952
     2953
     2954
     2955
    29122956    }
    29132957
  • branches/4.9/src/wp-includes/class-wp-query.php

    r46493 r47648  
    760760        } elseif ( $qv['p'] ) {
    761761            $this->is_single = true;
    762         } elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) {
    763             // If year, month, day, hour, minute, and second are set, a single
    764             // post is being queried.
    765             $this->is_single = true;
    766762        } elseif ( '' != $qv['pagename'] || !empty($qv['page_id']) ) {
    767763            $this->is_page = true;
  • branches/4.9/src/wp-includes/formatting.php

    r45994 r47648  
    17771777    $filename_raw = $filename;
    17781778    $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));
     1779
     1780
     1781
     1782
     1783
     1784
     1785
     1786
     1787
     1788
     1789
     1790
     1791
     1792
     1793
     1794
     1795
     1796
    17791797    /**
    17801798     * Filters the list of characters to remove from a filename.
     
    17861804     */
    17871805    $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
    1788     $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
    17891806    $filename = str_replace( $special_chars, '', $filename );
    17901807    $filename = str_replace( array( '%20', '+' ), '-', $filename );
  • branches/4.9/src/wp-includes/post.php

    r43707 r47648  
    31373137    global $wpdb;
    31383138
     3139
     3140
     3141
    31393142    $user_id = get_current_user_id();
    31403143
     
    34333436         *
    34343437         * @since 3.9.0
     3438
    34353439         *
    3436          * @param array $data    An array of sanitized attachment post data.
    3437          * @param array $postarr An array of unsanitized attachment post data.
     3440         * @param array $data                An array of slashed, sanitized, and processed attachment post data.
     3441         * @param array $postarr             An array of slashed and sanitized attachment post data, but not processed.
     3442         * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data
     3443         *                                   as originally passed to wp_insert_post().
    34383444         */
    3439         $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
     3445        $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
    34403446    } else {
    34413447        /**
     
    34433449         *
    34443450         * @since 2.7.0
     3451
    34453452         *
    3446          * @param array $data    An array of slashed post data.
    3447          * @param array $postarr An array of sanitized, but otherwise unmodified post data.
     3453         * @param array $data                An array of slashed, sanitized, and processed post data.
     3454         * @param array $postarr             An array of sanitized (and slashed) but otherwise unmodified post data.
     3455         * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as
     3456         *                                   originally passed to wp_insert_post().
    34483457         */
    3449         $data = apply_filters( 'wp_insert_post_data', $data, $postarr );
     3458        $data = apply_filters( 'wp_insert_post_data', $data, $postarr );
    34503459    }
    34513460    $data = wp_unslash( $data );
  • branches/4.9/src/wp-includes/user.php

    r43708 r47648  
    16931693
    16941694    if ( $update ) {
    1695         if ( $user_email !== $old_user_data->user_email ) {
     1695        if ( $user_email !== $old_user_data->user_email ) {
    16961696            $data['user_activation_key'] = '';
    16971697        }
  • branches/4.9/tests/phpunit/tests/customize/manager.php

    r42620 r47648  
    10911091
    10921092    /**
     1093
     1094
     1095
     1096
     1097
     1098
     1099
     1100
     1101
     1102
     1103
     1104
     1105
     1106
     1107
     1108
     1109
     1110
     1111
     1112
     1113
     1114
     1115
     1116
     1117
     1118
     1119
     1120
     1121
     1122
     1123
     1124
     1125
     1126
     1127
     1128
     1129
     1130
     1131
     1132
     1133
     1134
     1135
     1136
     1137
     1138
     1139
     1140
     1141
     1142
     1143
     1144
     1145
     1146
     1147
     1148
     1149
     1150
     1151
     1152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
     1163
     1164
     1165
     1166
     1167
     1168
     1169
     1170
     1171
     1172
     1173
     1174
     1175
     1176
     1177
     1178
     1179
     1180
     1181
     1182
     1183
     1184
     1185
     1186
     1187
     1188
     1189
     1190
     1191
     1192
     1193
     1194
     1195
     1196
     1197
     1198
     1199
     1200
     1201
     1202
     1203
     1204
     1205
     1206
     1207
     1208
     1209
     1210
     1211
     1212
     1213
     1214
     1215
     1216
     1217
     1218
     1219
     1220
     1221
     1222
     1223
     1224
     1225
     1226
     1227
     1228
     1229
     1230
     1231
     1232
     1233
     1234
     1235
     1236
     1237
     1238
     1239
     1240
     1241
     1242
     1243
     1244
     1245
     1246
     1247
     1248
     1249
     1250
     1251
     1252
     1253
     1254
     1255
     1256
     1257
    10931258     * Call count for customize_changeset_save_data filter.
    10941259     *
  • branches/4.9/tests/phpunit/tests/formatting/SanitizeFileName.php

    r37756 r47648  
    6868        $this->assertEquals( 'no-extension', sanitize_file_name( '_.no-extension' ) );
    6969    }
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
    7086}
  • branches/4.9/tests/phpunit/tests/user.php

    r43459 r47648  
    918918    }
    919919
    920     function test_changing_email_invalidates_password_reset_key() {
     920    function test_changing_email_invalidates_password_reset_key() {
    921921        global $wpdb;
    922922
     
    943943            'user_nicename' => 'cat',
    944944            'user_email'    => 'foo@bar.dev',
     945
     946
     947
     948
     949
     950
     951
     952
     953
     954
     955
     956
     957
     958
     959
     960
     961
     962
     963
     964
    945965        );
    946966        wp_update_user( $userdata );
Note: See TracChangeset for help on using the changeset viewer.