Make WordPress Core

Changeset 44837 for branches/4.8


Ignore:
Timestamp:
03/12/2019 10:20:10 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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

Merges [44833] to the 4.8 branch.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

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

    r42057 r44837  
    27352735    $rel  = 'nofollow';
    27362736
    2737     if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
    2738          preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
    2739     ) {
    2740         return "<a $text>";
     2737    if ( ! empty( $atts['href'] ) ) {
     2738        if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
     2739            if ( strtolower( wp_parse_url( $atts['href'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {
     2740                return "<a $text>";
     2741            }
     2742        }
    27412743    }
    27422744
     
    27512753        $html = '';
    27522754        foreach ( $atts as $name => $value ) {
    2753             $html .= "{$name}=\"$value\" ";
     2755            $html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
    27542756        }
    27552757        $text = trim( $html );
    27562758    }
    2757     return "<a $text rel=\"$rel\">";
     2759    return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
    27582760}
    27592761
Note: See TracChangeset for help on using the changeset viewer.