Changeset 45990
- Timestamp:
- 09/04/2019 05:36:46 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r45932 r45990 3044 3044 function wp_rel_nofollow_callback( $matches ) { 3045 3045 $text = $matches[1]; 3046 $atts = shortcode_parse_atts( $matches[1]);3046 $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); 3047 3047 $rel = 'nofollow'; 3048 3048 3049 3049 if ( ! empty( $atts['href'] ) ) { 3050 if ( in_array( strtolower( wp_parse_url( $atts['href'] , PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {3051 if ( strtolower( wp_parse_url( $atts['href'] , PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {3050 if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) { 3051 if ( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) { 3052 3052 return "<a $text>"; 3053 3053 } … … 3056 3056 3057 3057 if ( ! empty( $atts['rel'] ) ) { 3058 $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );3058 $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); 3059 3059 if ( false === array_search( 'nofollow', $parts ) ) { 3060 3060 $parts[] = 'nofollow'; … … 3065 3065 $html = ''; 3066 3066 foreach ( $atts as $name => $value ) { 3067 $html .= "{$name}=\"" . esc_attr( $value ) . '" '; 3067 if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { 3068 $html .= $name . ' '; 3069 } else { 3070 $html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; 3071 } 3068 3072 } 3069 3073 $text = trim( $html ); -
trunk/tests/phpunit/tests/formatting/WPRelNoFollow.php
r42343 r45990 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.