Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#26868 new enhancement

Function 'make_clickable()' doesn't make hyperlinks from explicit URLs using the `mailto:`, `tel:` and other schemes that do not start with `//`

Reported by: mdgl's profile mdgl Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8
Component: Formatting Keywords: needs-unit-tests dev-feedback needs-testing
Focuses: Cc:

Description

Function make_clickable() tries to recognise URLs and convert these into clickable hyperlinks. The function is by default configured as a filter for comment text.

Unfortunately, the function assumes that all explicitly declared URLs begin with the string // after the scheme and colon parts which is not the case for the mailto:, tel: and many other schemes. Such URLs could usefully be made clickable, especially for use on smartphones and tablets.

This also leads to inconsistencies between explicitly and implicitly declared URLs. For example, the string myemail@mydomain.com is converted into a clickable hyperlink whilst the string mailto:myemail@mydomain.com is not.

By contrast, the TinyMCE post editor correctly and automatically makes both implicit and explicit mailto: links clickable but does nothing with tel:.

For reference, the syntax of URLs is defined by http://tools.ietf.org/html/std66, the mailto: scheme by http://tools.ietf.org/html/rfc6068 and that for tel: by http://tools.ietf.org/html/rfc3966.

As #16892 has illustrated, parsing URLs can be hard. The use of wp_allowed_protocols() may help in detecting which strings we wish to make clickable.

Found whilst testing #22946.

Attachments (1)

26868.patch (1.0 KB) - added by jbkkd 11 years ago.
This makes the trailing optional. This is by no means a full solution, as it would allow http:example.com, but works as a good workaround to allow mailto: and friends, while still maintaining the same functionality

Download all attachments as: .zip

Change History (5)

#1 @nacin
11 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

I think this would be cool if it doesn't have performance issues.

That said, make_clickable() isn't currently designed to work this way, so it's safe to classify this as an enhancement.

@jbkkd
11 years ago

This makes the trailing optional. This is by no means a full solution, as it would allow http:example.com, but works as a good workaround to allow mailto: and friends, while still maintaining the same functionality

#2 @jbkkd
11 years ago

The correct comment above:
This makes the trailing // optional. This is by no means a full solution, as it would allow http:example.com, but works as a good workaround to allow mailto: and friends, while still maintaining the same functionality

#3 @jbkkd
11 years ago

  • Keywords dev-feedback added; needs-patch removed

#4 @chriscct7
9 years ago

  • Keywords needs-testing added
Note: See TracTickets for help on using tickets.