Make WordPress Core


Ignore:
Timestamp:
10/14/2019 07:26:08 PM (7 years ago)
Author:
whyisjake
Message:

Backporting several bug fixes.

  • Query: Remove the static query property.
  • HTTP API: Protect against hex interpretation.
  • Filesystem API: Prevent directory travelersals when creating new folders.
  • Administration: Ensure that admin referer nonce is valid.
  • REST API: Send a Vary: Origin header on GET requests.
  • Customizer: Properly sanitize background images.

Backports [46474], [46475], [46476], [46477], [46478], [46483], [46485] to the 3.9 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9/src/wp-includes/pluggable.php

    r45986 r46503  
    10071007 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    10081008 */
    1009 function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
    1010         if ( -1 == $action )
    1011                 _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
     1009function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
     1010        if ( -1 === $action )
     1011                _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
    10121012
    10131013        $adminurl = strtolower(admin_url());
    … …  
    10281028         */
    10291029        do_action( 'check_admin_referer', $action, $result );
     1030
     1031        if ( ! $result && ! ( -1 === $action && strpos( $referer, $adminurl ) === 0 ) ) {
     1032                wp_nonce_ays( $action );
     1033                die();
     1034        }
     1035
    10301036        return $result;
    10311037}
    … …  
    10421048 */
    10431049function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
     1050        if ( -1 === $action )
     1051                _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
     1052
    10441053        $nonce = '';
    10451054
    … …  
    22202229}
    22212230endif;
    2222 
    2223 if ( ! function_exists( 'hash_equals' ) ) :
    2224 /**
    2225  * Compare two strings in constant time.
    2226  *
    2227  * This function is NOT pluggable. It is in this file (in addition to
    2228  * compat.php) to prevent errors if, during an update, pluggable.php
    2229  * copies over but compat.php does not.
    2230  *
    2231  * This function was added in PHP 5.6.
    2232  * It can leak the length of a string.
    2233  *
    2234  * @since 3.9.2
    2235  *
    2236  * @param string $a Expected string.
    2237  * @param string $b Actual string.
    2238  * @return bool Whether strings are equal.
    2239  */
    2240 function hash_equals( $a, $b ) {
    2241         $a_length = strlen( $a );
    2242         if ( $a_length !== strlen( $b ) ) {
    2243                 return false;
    2244         }
    2245         $result = 0;
    2246 
    2247         // Do not attempt to "optimize" this.
    2248         for ( $i = 0; $i < $a_length; $i++ ) {
    2249                 $result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
    2250         }
    2251 
    2252         return $result === 0;
    2253 }
    2254 endif;
Note: See TracChangeset for help on using the changeset viewer.