Make WordPress Core


Ignore:
Timestamp:
03/12/2019 10:18:57 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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

Merges [44833] to the 4.9 branch.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

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

    r43444 r44836  
    27512751    $rel  = 'nofollow';
    27522752
    2753     if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
    2754          preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
    2755     ) {
    2756         return "<a $text>";
     2753    if ( ! empty( $atts['href'] ) ) {
     2754        if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
     2755            if ( strtolower( wp_parse_url( $atts['href'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {
     2756                return "<a $text>";
     2757            }
     2758        }
    27572759    }
    27582760
     
    27672769        $html = '';
    27682770        foreach ( $atts as $name => $value ) {
    2769             $html .= "{$name}=\"$value\" ";
     2771            $html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
    27702772        }
    27712773        $text = trim( $html );
    27722774    }
    2773     return "<a $text rel=\"$rel\">";
     2775    return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
    27742776}
    27752777
Note: See TracChangeset for help on using the changeset viewer.