Make WordPress Core


Ignore:
Timestamp:
03/12/2019 10:21:44 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Formatting: Improve rel="nofollow" handling in comments.

Merges [44833] to the 4.7 branch.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/formatting.php

    r40091 r44838  
    27342734    $rel  = 'nofollow';
    27352735
    2736     if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
    2737          preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
    2738     ) {
    2739         return "<a $text>";
     2736    if ( ! empty( $atts['href'] ) ) {
     2737        if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
     2738            if ( strtolower( wp_parse_url( $atts['href'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {
     2739                return "<a $text>";
     2740            }
     2741        }
    27402742    }
    27412743
     
    27502752        $html = '';
    27512753        foreach ( $atts as $name => $value ) {
    2752             $html .= "{$name}=\"$value\" ";
     2754            $html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
    27532755        }
    27542756        $text = trim( $html );
    27552757    }
    2756     return "<a $text rel=\"$rel\">";
     2758    return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
    27572759}
    27582760
Note: See TracChangeset for help on using the changeset viewer.