Ticket #3228 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

make_clickable() doesn't make all links clickable

Reported by: mdawaffe Assigned to: markjaquith
Priority: normal Milestone:
Component: Template Version:
Severity: normal Keywords:
Cc:

Description (Last modified by markjaquith)

If a link is the first string after a tag such as <p>http://wordpress.org ... or <em>http://wordpress.org/</em>, the link is not made clickable.

2.0.5? [4012] (the change that broke this) went into branches/2.0

Attachments

make_clickable.php (2.0 kB) - added by markjaquith on 10/13/06 03:27:39.
Test Old vs. New vs. Proposed

Change History

10/10/06 19:00:42 changed by Viper007Bond

  • component changed from Administration to Template.

I think you meant [4012]. ;)

10/10/06 22:31:28 changed by mdawaffe

Yes, I did mean [4012]. Thanks :)

10/11/06 09:09:41 changed by markjaquith

  • description changed.

10/13/06 03:27:39 changed by markjaquith

  • attachment make_clickable.php added.

Test Old vs. New vs. Proposed

10/13/06 03:32:42 changed by markjaquith

  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.

Check out that upload. I've been playing with that (was testing in PHP console, so add htmlspecialchars() and <hr /> if you're testing in a browser)

My fix is simple to look for anchors within anchors, and removing the internal (undesired) anchor (the one created by our function).

For people who just want to see the results, here is the input of my script:

<p>http://example.com/ is a link.  So is: http://example.com/</p>
<p><a href="http://example.com/">example.com</a></p>
<p>www.example.com/signup/</p>
<p>ftp.example.org</p>
<p>example@example.com</p>
<p>ftp://example.com/foo/bar/</p>

Here is the output of that script.

Old function (WP < 2.0.4):

<p><a href='http://example.com/' rel='nofollow'>http://example.com/</a> is a link.  So is: <a href='http://example.com/' rel='nofollow'>http://example.com/</a></p>
<p><a href="http://example.com/">example.com</a></p>
<p>www.example.com/signup/</p>
<p>ftp.example.org</p>
<p>example@example.com</p>
<p>ftp://example.com/foo/bar/</p>

New function (2.0.4 and currently in trunk):

<p>http://example.com/ is a link.  So is: <a href='http://example.com/' rel='nofollow'>http://example.com/</a></p>
<p><a href="http://example.com/">example.com</a></p>
<p>www.example.com/signup/</p>
<p>ftp.example.org</p>
<p>example@example.com</p>
<p>ftp://example.com/foo/bar/</p>

My proposed function:

<p><a href='http://example.com/' rel='nofollow'>http://example.com/</a> is a link.  So is: <a href='http://example.com/' rel='nofollow'>http://example.com/</a></p>
<p><a href="http://example.com/">example.com</a></p>
<p><a href='http://www.example.com/signup/' rel='nofollow'>www.example.com/signup/</a></p>
<p><a href='http://ftp.example.org' rel='nofollow'>ftp.example.org</a></p>
<p><a href="mailto:example@example.com">example@example.com</a></p>
<p><a href='ftp://example.com/foo/bar/' rel='nofollow'>ftp://example.com/foo/bar/</a></p>

This is the last remaining ticket for 2.0.5 ... help a brother out!

10/13/06 03:37:12 changed by markjaquith

And just to outline the problem that necessitated the change from old to new, and the problem introduced by new:

Input:

<p><a href="http://example.com/">http://example.com/</a></p>
<p>http://example.com</p>

Old:

<p><a href="http://example.com/"><a href='http://example.com/' rel='nofollow'>http://example.com/</a></a></p>
<p><a href='http://example.com' rel='nofollow'>http://example.com</a></p>

New:

<p><a href="http://example.com/">http://example.com/</a></p>
<p>http://example.com</p>

Proposed:

<p><a href="http://example.com/">http://example.com/</a></p>
<p><a href='http://example.com' rel='nofollow'>http://example.com</a></p>

10/13/06 06:01:19 changed by markjaquith

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [4385]) make_clickable() now faster and supports more link positions, from mdawaffe and myself. fixes #3228

10/13/06 06:01:35 changed by markjaquith

(In [4386]) make_clickable() now faster and supports more link positions, from mdawaffe and myself. fixes #3228

10/13/06 06:08:30 changed by markjaquith

(In [4387]) fix function name error in last two commits. fixes #3228

11/30/06 19:41:51 changed by

  • milestone deleted.

Milestone 2.0.5 deleted