Make WordPress Core

Ticket #27152: 27152.2.diff

File 27152.2.diff, 1.4 KB (added by swissspidy, 8 years ago)
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index be01132..7ac667b 100644
    function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { 
    15171517 * @return false|string False on failure. Referer URL on success.
    15181518 */
    15191519function wp_get_referer() {
    1520         if ( ! function_exists( 'wp_validate_redirect' ) )
     1520        if ( ! function_exists( 'wp_validate_redirect' ) ) {
    15211521                return false;
    1522         $ref = false;
    1523         if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
    1524                 $ref = wp_unslash( $_REQUEST['_wp_http_referer'] );
    1525         elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) )
    1526                 $ref = wp_unslash( $_SERVER['HTTP_REFERER'] );
     1522        }
     1523
     1524        $ref = wp_get_raw_referer();
    15271525
    15281526        if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) )
    15291527                return wp_validate_redirect( $ref, false );
    function wp_get_referer() { 
    15311529}
    15321530
    15331531/**
     1532 * Retrieve unvalidated referer from '_wp_http_referer' or HTTP referer.
     1533 *
     1534 * @since 4.5.0
     1535 *
     1536 * @return string|bool Referer URL on success, false on failure.
     1537 */
     1538function wp_get_raw_referer() {
     1539        if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
     1540                return wp_unslash( $_REQUEST['_wp_http_referer'] );
     1541        } else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
     1542                return wp_unslash( $_SERVER['HTTP_REFERER'] );
     1543        }
     1544
     1545        return false;
     1546}
     1547
     1548/**
    15341549 * Retrieve original referer that was posted, if it exists.
    15351550 *
    15361551 * @since 2.0.4