Skip to content
Permalink
Browse files

WP-r44836: Formatting: Improve `rel="nofollow"` handling in comments.

  • Loading branch information...
SergeyBiryukov authored and nylen committed Mar 13, 2019
1 parent 5b307ce commit d949ee8f70fb4c1d050bdeb7a543844ba738169a
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/wp-includes/formatting.php
@@ -2750,10 +2750,12 @@ function wp_rel_nofollow_callback( $matches ) {
$atts = shortcode_parse_atts( $matches[1] );
$rel = 'nofollow';
if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
) {
return "<a $text>";
if ( ! empty( $atts['href'] ) ) {
if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
if ( strtolower( wp_parse_url( $atts['href'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {
return "<a $text>";
}
}
}
if ( ! empty( $atts['rel'] ) ) {
@@ -2766,11 +2768,11 @@ function wp_rel_nofollow_callback( $matches ) {
$html = '';
foreach ( $atts as $name => $value ) {
$html .= "{$name}=\"$value\" ";
$html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
}
$text = trim( $html );
}
return "<a $text rel=\"$rel\">";
return "<a $text rel=\"" . esc_attr( $rel ) . "\">";
}
/**

0 comments on commit d949ee8

Please sign in to comment.
You can’t perform that action at this time.