Skip to content

URL Fieldtype wants incorrect tel:// protocol instead of tel: #5453

Open

Description

@jaredchesebro

Description of the problem

The URL fieldtype's "Allowed URL schemes" setting offers tel:// as an option, but there is no tel: option. tel:// is not a valid form of the tel URI scheme.

Per RFC 3966, a telephone URI is tel: followed directly by the number (e.g. tel:+1-555-555-1234). It has no authority component, so there is no // like there is in http:// or ftp://.

This matters in practice:

  • Entering a correct tel: link (e.g. tel:+15555551234) fails validation even when tel:// is checked in the field settings, so authors are pushed into entering the wrong format.
  • tel:// links can fail to trigger click-to-call in some browsers and mobile OSes, because the dialer doesn't recognize the malformed URI.

I expected to be able to allow and enter standard tel: links, the same way mailto: works today.

How To Reproduce

  1. Create a URL field.
  2. In the field settings, check tel:// under "Allowed URL schemes."
  3. Edit an entry and enter tel:+15555551234 in the field.
  4. Save. Validation fails with the invalid URL scheme error.
  5. Change the value to tel://+15555551234 and save. It passes, but it's an invalid tel URI.

Screenshots / Videos / Template Code

URL fieldtype protocols

Environment Details:

  • Version: 7.5.28
  • PHP Version: 8.3
  • MySQL Version: mariadb 11.4
  • OS: Alpine Linux (DDEV)
  • Web Server: NGINX (DDEV)

Possible Solution

Add tel: as its own allowed scheme, following the existing mailto: precedent in system/ee/ExpressionEngine/Addons/url/ft.url.php (checked against 7.5.28).

In getSchemes(), add a tel: option:

'mailto:' => 'mailto:',
'sftp://' => 'sftp://',
'ssh://' => 'ssh://',
'tel:' => 'tel:',
'tel://' => 'tel://',

In validate(), add a tel check right after the existing mailto check in the "no host" branch:

if (
    isset($parsed_url['scheme'], $parsed_url['path']) &&
    $parsed_url['scheme'] == 'tel' &&
    in_array('tel:', $this->get_setting('allowed_url_schemes'))
) {
    return true;
}

Keeping tel:// in the list avoids breaking existing field settings and entries. It could be deprecated or removed in a future major version.

Additional context

This has been around for years. It looks like tel was grouped with the hierarchical schemes (ftp://, sftp://, ssh://) when it belongs with mailto:.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions