WordPress.org

Make WordPress Core

Changeset 44835


Ignore:
Timestamp:
03/12/2019 10:17:34 PM (6 months ago)
Author:
SergeyBiryukov
Message:

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

Merges [44833] to the 5.0 branch.

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

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

    r43930 r44835  
    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.