Make WordPress Core

Changeset 55495


Ignore:
Timestamp:
03/09/2023 12:18:29 AM (22 months ago)
Author:
SergeyBiryukov
Message:

Formatting: Restore consistent quotes in _make_web_ftp_clickable_cb().

After the introduction of _make_clickable_rel_attr() in an earlier commit, the function ended up returning link markup with a mix of single and double quotes.

This commit ensures that _make_web_ftp_clickable_cb() always returns double quotes, restoring consistency with other similar callback functions used by make_clickable():

  • _make_url_clickable_cb()
  • _make_email_clickable_cb()

Follow-up to [55289].

See #53290, #56444.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r55398 r55495  
    240240         * @since 6.2.0
    241241         *
    242          * @param string[]   $rel_parts An array of strings representing the rel
    243          *                              tags which will be joined into the anchor's
    244          *                              rel attribute.
    245          * @param WP_Comment $comment   The comment object
     242         * @param string[]   $rel_parts An array of strings representing the rel tags
     243         *                              which will be joined into the anchor's rel attribute.
     244         * @param WP_Comment $comment   The comment object.
    246245         */
    247246        $rel_parts = apply_filters( 'comment_author_link_rel', $rel_parts, $comment );
     
    249248        $rel = implode( ' ', $rel_parts );
    250249        $rel = esc_attr( $rel );
    251         // empty space before rel necessary for later sprintf.
     250        // Empty space before 'rel' is necessary for later sprintf().
    252251        $rel = ! empty( $rel ) ? sprintf( ' rel="%s"', $rel ) : '';
    253252
  • trunk/src/wp-includes/formatting.php

    r55414 r55495  
    29192919
    29202920    $rel_attr = _make_clickable_rel_attr( $url );
    2921     return $matches[1] . "<a href=\"$url\"$rel_attr>$url</a>" . $suffix;
    2922 
     2921
     2922    return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix;
    29232923}
    29242924
     
    29522952
    29532953    $rel_attr = _make_clickable_rel_attr( $dest );
    2954     return $matches[1] . "<a href='{$dest}'{$rel_attr}>{$dest}</a>{$ret}";
     2954
     2955    return $matches[1] . "<a href=\"{$dest}\"{$rel_attr}>{$dest}</a>{$ret}";
    29552956}
    29562957
     
    29682969function _make_email_clickable_cb( $matches ) {
    29692970    $email = $matches[2] . '@' . $matches[3];
    2970     return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
     2971
     2972    return $matches[1] . "<a href=\"mailto:{$email}\">{$email}</a>";
    29712973}
    29722974
     
    29802982 */
    29812983function _make_clickable_rel_attr( $url ) {
    2982 
    29832984    $rel_parts        = array();
    29842985    $scheme           = strtolower( wp_parse_url( $url, PHP_URL_SCHEME ) );
     
    30103011
    30113012    return $rel_attr;
    3012 
    30133013}
    30143014
  • trunk/tests/phpunit/tests/formatting/makeClickable.php

    r55289 r55495  
    109109        );
    110110        $urls_expected = array(
    111             "<a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>",
    112             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>. Alice!",
    113             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>, said Alice.",
    114             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>; said Alice.",
    115             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>: said Alice.",
    116             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>) said Alice.",
     111            '<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
     112            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>. Alice!',
     113            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>, said Alice.',
     114            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>; said Alice.',
     115            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>: said Alice.',
     116            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>) said Alice.',
    117117        );
    118118
     
    136136        );
    137137        $urls_expected = array(
    138             "<a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>",
    139             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>.",
    140             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>,",
    141             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>;",
    142             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>:",
    143             "There was a spoon named <a href='http://www.wordpress.org' rel=\"nofollow\">http://www.wordpress.org</a>)",
     138            '<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
     139            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>.',
     140            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>,',
     141            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>;',
     142            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>:',
     143            'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>)',
    144144        );
    145145
     
    440440
    441441    public function data_add_rel_ugc_in_comments() {
    442 
    443442        $home_url_http  = set_url_scheme( home_url(), 'http' );
    444443        $home_url_https = set_url_scheme( home_url(), 'https' );
     
    452451            array(
    453452                'www.wordpress.org',
    454                 '<p><a href=\'http://www.wordpress.org\' rel="nofollow ugc">http://www.wordpress.org</a>',
     453                '<p><a href="http://www.wordpress.org" rel="nofollow ugc">http://www.wordpress.org</a>',
    455454            ),
    456455            // @ticket 56444
    457456            array(
    458457                'www.example.org',
    459                 '<p><a href=\'http://www.example.org\' rel="nofollow ugc">http://www.example.org</a>',
     458                '<p><a href="http://www.example.org" rel="nofollow ugc">http://www.example.org</a>',
    460459            ),
    461460            array(
Note: See TracChangeset for help on using the changeset viewer.