Changeset 45995 for branches/4.8
- Timestamp:
- 09/04/2019 05:47:22 PM (5 years ago)
- Location:
- branches/4.8
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
-
branches/4.8/src/wp-includes/formatting.php
r44837 r45995 2732 2732 function wp_rel_nofollow_callback( $matches ) { 2733 2733 $text = $matches[1]; 2734 $atts = shortcode_parse_atts( $matches[1]);2734 $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); 2735 2735 $rel = 'nofollow'; 2736 2736 2737 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 ) ) ) {2738 if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) { 2739 if ( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) { 2740 2740 return "<a $text>"; 2741 2741 } … … 2744 2744 2745 2745 if ( ! empty( $atts['rel'] ) ) { 2746 $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );2746 $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); 2747 2747 if ( false === array_search( 'nofollow', $parts ) ) { 2748 2748 $parts[] = 'nofollow'; … … 2753 2753 $html = ''; 2754 2754 foreach ( $atts as $name => $value ) { 2755 $html .= "{$name}=\"" . esc_attr( $value ) . "\" "; 2755 if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { 2756 $html .= $name . ' '; 2757 } else { 2758 $html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; 2759 } 2756 2760 } 2757 2761 $text = trim( $html ); -
branches/4.8/tests/phpunit/tests/formatting/WPRelNoFollow.php
r36125 r45995 75 75 ); 76 76 } 77 78 public function test_append_no_follow_with_valueless_attribute() { 79 $content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>'; 80 $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow\">Code</a></p>'; 81 $this->assertEquals( $expected, wp_rel_nofollow( $content ) ); 82 } 77 83 }
Note: See TracChangeset
for help on using the changeset viewer.