[wp-trac] [WordPress Trac] #59682: Bug fix for rel attributes in social-link.php

WordPress Trac noreply at wordpress.org
Mon Oct 30 11:44:16 UTC 2023


#59682: Bug fix for rel attributes in social-link.php
--------------------------+------------------------------
 Reporter:  niallhotfoot  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  6.3.2
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+------------------------------

Comment (by dmsnell):

 @niallhotfoot I performed some testing with the following file

 {{{
 <li><a href="noopener-child.html" target="tester">Open</a></li>
 <li><a href="noopener-child.html" target="tester" rel="noopener">Open with
 noopener</a></li>
 <li><a href="noopener-child.html" target="tester" rel=" noopener">Open
 with _noopener</a></li>
 }}}


 All three cases worked the way I expected, where the leading space didn't
 have an impact on the `rel` attribute. This matches the HTML
 specification, indicating that the value is a space-separated list of
 tokens.

 > the noopener nofollow was not being added at all

 This might be a clue; I wonder if some other filter is running and looking
 for something naive, such as something looking for `str_starts_with( $rel,
 "noopener" )`

 I searched Core's code and couldn't find anything, then tested
 `wp_targeted_link_rel()` and couldn't find a way to mess it up. Can you
 share the setup you have which led to the missing `rel` value? Did you
 have to perform any steps?

 {{{#!php
 <?php
 wp_targeted_link_rel( '<a href="https://page.com" target="testing">' );
 // "<a href="https://page.com" target="testing" rel="noopener">"

 wp_targeted_link_rel( '<a href="https://page.com" target="testing"
 rel="noopener">' );
 // "<a href="https://page.com" target="testing" rel="noopener">"

 wp_targeted_link_rel( '<a href="https://page.com" target="testing" rel="
 noopener">' );
 // "<a href="https://page.com" target="testing" rel="noopener">"

 php > var_dump( wp_targeted_link_rel( '<a href="https://page.com"
 target="testing" rel=" noopener nofollow">' );
 // "<a href="https://page.com" target="testing" rel="noopener nofollow">"

 wp_targeted_link_rel( '<a href="https://page.com" target="testing" rel="
 ">' );
 // "<a href="https://page.com" target="testing" rel="noopener">"

 wp_targeted_link_rel( '<a href="https://page.com" target="testing"
 rel="">' );
 // "<a href="https://page.com" target="testing" rel="noopener">"
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59682#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list