[wp-meta] [Making WordPress.org] #3998: Support Forums: Incorrect link conversion

Making WordPress.org noreply at wordpress.org
Wed Dec 19 07:23:57 UTC 2018

#3998: Support Forums: Incorrect link conversion
 Reporter:  SergeyBiryukov  |       Owner:  (none)
     Type:  defect          |      Status:  closed
 Priority:  normal          |   Milestone:
Component:  Support Forums  |  Resolution:  invalid
 Keywords:                  |
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid


 This is a problem in `bbp_make_clickable()`, but is also present in

 Given the input string of `<a href="https://codex.wordpress.org/Roles and
 Capabilities">https://codex.wordpress.org/Roles and Capabilities</a>` both
 will return the invalid output.

 Both contain the following to correct it:
 return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a
 [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
 But as the resulting HTML is the following it's not matched (due to the
 `</a></a>` - which assumes that neither the linked text never has spaces
 or isn't a URL)
 <a href="https://codex.wordpress.org/Roles and Capabilities"><a
 rel="nofollow">https://codex.wordpress.org/Roles</a> and Capabilities</a>

 Adjusting the regular expression to the following does work however:
 return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a
 [^>]+?>([^>]+?)</a>([^<]*)</a>#i', "$1$3$4</a>", $r );

 As a work around, you can remove the spaces from the linked text, which
 avoids it:
 `<a href="https://codex.wordpress.org/Roles and
 Capabilities">https://codex.wordpress.org/Roles and Capabilities</a>`.

 I'm going to call this a bug in WordPress and bbPress.
 Closing in favour of https://bbpress.trac.wordpress.org/ticket/3237 &

Ticket URL: <https://meta.trac.wordpress.org/ticket/3998#comment:1>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org

More information about the wp-meta mailing list