Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3998 closed defect (bug) (reported-upstream)

Support Forums: Incorrect link conversion

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by:
Milestone: Priority: normal
Component: Support Forums Keywords:


<a href=" and Capabilities"> and Capabilities</a>

turns into:

<a href=" and Capabilities" rel="nofollow"></a><a href="" rel="nofollow"></a> and Capabilities

Looks like either make_clickable() or bbp_make_clickable() is trying to make the URL clickable without taking the existing <a> tag into account.

Change History (3)

#1 @dd32
5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

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

Given the input string of <a href=" and Capabilities"> 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=" and Capabilities"><a href="" rel="nofollow"></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=" and Capabilities">;and&nbsp;Capabilities</a>.

I'm going to call this a bug in WordPress and bbPress.
Closing in favour of &

#2 @dd32
5 years ago

  • Resolution changed from invalid to reported-upstream
Note: See TracTickets for help on using tickets.