Make WordPress Core


Ignore:
Timestamp:
09/04/2019 05:53:08 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Improve handling the existing rel attribute in wp_rel_nofollow_callback().

Merges [45990] to the 4.5 branch.
Props xknown, sstoqnov.

Location:
branches/4.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5

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

    r44865 r45999  
    23482348function wp_rel_nofollow_callback( $matches ) {
    23492349        $text = $matches[1];
    2350         $atts = shortcode_parse_atts( $matches[1] );
     2350        $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() );
    23512351        $rel  = 'nofollow';
    23522352
    23532353        if ( ! empty( $atts['href'] ) ) {
    2354                 $href_parts  = wp_parse_url( $atts['href'] );
     2354                $href_parts  = wp_parse_url( $atts['href']['value'] );
    23552355                $href_scheme = isset( $href_parts['scheme'] ) ? $href_parts['scheme'] : '';
    23562356                $href_host   = isset( $href_parts['host'] ) ? $href_parts['host'] : '';
    … …  
    23652365
    23662366        if ( ! empty( $atts['rel'] ) ) {
    2367                 $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );
     2367                $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) );
    23682368                if ( false === array_search( 'nofollow', $parts ) ) {
    23692369                        $parts[] = 'nofollow';
    … …  
    23742374                $html = '';
    23752375                foreach ( $atts as $name => $value ) {
    2376                         $html .= "{$name}=\"" . esc_attr( $value ) . "\" ";
     2376                        if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) {
     2377                                $html .= $name . ' ';
     2378                        } else {
     2379                                $html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" ';
     2380                        }
    23772381                }
    23782382                $text = trim( $html );
Note: See TracChangeset for help on using the changeset viewer.