Changeset 45992
- Timestamp:
- 09/04/2019 05:40:11 PM (4 years ago)
- Location:
- branches/5.1
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.1
-
branches/5.1/src/wp-includes/formatting.php
r44859 r45992 3002 3002 function wp_rel_nofollow_callback( $matches ) { 3003 3003 $text = $matches[1]; 3004 $atts = shortcode_parse_atts( $matches[1]);3004 $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); 3005 3005 $rel = 'nofollow'; 3006 3006 3007 3007 if ( ! empty( $atts['href'] ) ) { 3008 if ( in_array( strtolower( wp_parse_url( $atts['href'] , PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {3009 if ( strtolower( wp_parse_url( $atts['href'] , PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {3008 if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) { 3009 if ( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) { 3010 3010 return "<a $text>"; 3011 3011 } … … 3014 3014 3015 3015 if ( ! empty( $atts['rel'] ) ) { 3016 $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );3016 $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); 3017 3017 if ( false === array_search( 'nofollow', $parts ) ) { 3018 3018 $parts[] = 'nofollow'; … … 3023 3023 $html = ''; 3024 3024 foreach ( $atts as $name => $value ) { 3025 $html .= "{$name}=\"" . esc_attr( $value ) . '" '; 3025 if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { 3026 $html .= $name . ' '; 3027 } else { 3028 $html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; 3029 } 3026 3030 } 3027 3031 $text = trim( $html ); -
branches/5.1/tests/phpunit/tests/formatting/WPRelNoFollow.php
r42343 r45992 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.