Enter a phone number in proper format +49 (89) 1234567 and you get

<a href="tel:%2B49%2889%291234567">+49 (89) 1234567</a>

No mobile phone or desktop application understand this. Everything that is not a number need to be removed as I know. I'm myself not sure what need to be done with #2004142: Vanity numbers may need conversion to numbers

CommentFileSizeAuthor
#9 tel_link_is-2004144-9.patch1.24 KBjeroent

Comments

hass’s picture

The regex need to be as below, but that's not all.

$href = 'tel:' . rawurlencode(preg_replace('/[^0-9]/', '', $item['value']));
dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

I'm reading http://www.ietf.org/rfc/rfc2806.txt and seeing that use of characters like 'w' or 'p' are acceptable as wait or pause characters. We should probably remove all non alpha-numeric characters? Do we strip out the plus sign or not for international?

hass’s picture

Status: Postponed (maintainer needs more info) » Active

I would convert + into 00 as this is the normal conversion phones do. It was new to me that w & p are doing this, but ok... If I remember correctly a "," is a wait and a # has special meaning on mobiles... Otherwise if we may cannot convert from vanity numbers.

bleen’s picture

the "+" char has meaning when it is not the first char (at least on iOS and Android) ... it means "wait for user input". Ex. 5555555555+123 will dial then number and then add a "Dial 123" button to the keypad screen

The comma means wait 2 seconds before continuing

As far as I can tell the "#" and "*" have no meaning, but they should not be removed because of things like conference numbers and voicemails. They are valid.

bleen’s picture

re #2 this is a slightly new version of the standard you referenced: http://tools.ietf.org/html/rfc3966#section-5.3 ... still old (circa 2004) but I cant find anything better.

That said, according to this the pause chars have been removed. However, since both android & ios support "+" and "," I think we should keep them. I'm working on an issue for html5_tools here: https://durpal.org/node/2062619 and plan to keep those characters in that issue FWIW.

frederickjh’s picture

Issue summary: View changes

@hass Converting + to 00 is a bad idea as not all countries use 00 as the international access code. The reason cellphone companies came up with the + as the international access code is so people would not need to figure out what country they were calling from and then figure out what access code to use.

jhedstrom’s picture

However, since both android & ios support "+" and "," I think we should keep them

Is there anything left to be done here?

hass’s picture

Yes. All.

jeroent’s picture

Title: tel: link is impropperly formated » tel: link is improperly formatted
Status: Active » Needs review
StatusFileSize
new1.24 KB

Wrote a test that checks if telephone numbers are properly formatted in the href attribute. This patch should fail.

Status: Needs review » Needs work

The last submitted patch, 9: tel_link_is-2004144-9.patch, failed testing.

The last submitted patch, 9: tel_link_is-2004144-9.patch, failed testing.

hass’s picture

We should verify http://www.ietf.org/rfc/rfc2806.txt - maybe I was totally wrong when I started the case.

RFC 2806                URLs for Telephone Calls              April 2000


                        ; See sections 1.2 and 2.5.2
service-provider      = ";" provider-tag "=" provider-hostname
provider-tag          = "tsp"
provider-hostname     = domain ; <domain> is defined in [RFC1035]
                        ; See section 2.5.10
future-extension      = ";" 1*(token-char) ["=" ((1*(token-char)
                        ["?" 1*(token-char)]) / quoted-string )]
                        ; See section 2.5.11 and [RFC2543]
token-char            = (%x21 / %x23-27 / %x2A-2B / %x2D-2E / %x30-39
                        / %x41-5A / %x5E-7A / %x7C / %x7E)
                        ; Characters in URLs must follow escaping rules
                        ; as explained in [RFC2396]
                        ; See sections 1.2 and 2.5.11
quoted-string         = %x22 *( "\" CHAR / (%x20-21 / %x23-7E
                        / %x80-FF )) %x22
                        ; Characters in URLs must follow escaping rules
                        ; as explained in [RFC2396]
                        ; See sections 1.2 and 2.5.11
phonedigit            = DIGIT / visual-separator
visual-separator      = "-" / "." / "(" / ")"
pause-character       = one-second-pause / wait-for-dial-tone
one-second-pause      = "p"
wait-for-dial-tone    = "w"
dtmf-digit            = "*" / "#" / "A" / "B" / "C" / "D"

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

madmanmax’s picture

Maybe would be an idea to use this library giggsey/libphonenumber-for-php for validating/formatting a phone number? It's a PHP port of Google's library for parsing, formatting, and validating international phone numbers.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pfrenssen’s picture

I like the idea of using giggsey/libphonenumber-for-php. It is able to handle whatever local format people enter their number in, and convert it to a standard format. It also opens the door for some awesome future additions to the Phone module.

mallezie’s picture

Should we create a #telephone form field herefore?

madmanmax’s picture

Isn't there already a form element #tel?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

zaporylie’s picture

  1. We already have #tel form element in place
  2. I'm all into having giggsey/libphonenumber-for-php in root composer.json. Contrib modules already use it to provide validation to telephone field. We could use it for proper formatting, but we must first store it in right way.
  3. I suggest creating separate issue for adding giggsey/libphonenumber-for-php to drupal core and make this one and similar issues be postponed by that one.
pfrenssen’s picture

We don't haphazardly add dependencies to core so that future issues can use it. I think we should probably make a contrib module with an example implementation first which can later be considered for inclusion in core.
I have an example of a really simple libphonenumber based field here: https://www.drupal.org/project/libphonenumber

zaporylie’s picture

Version: 8.3.x-dev » 8.4.x-dev

1. Bumping core version.

2. I created telephone_formatter module which adds extra telephone field formatter to core's telephone field and, by using giggsey/libphonenumber-for-php, formats the link using E164 format. If number cannot be parsed by giggsey/libphonenumber-for-php it displays fallback raw, unformatted value.
I believe we could use the same approach in core.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mlncn’s picture

Can we bring https://www.drupal.org/project/telephone_formatter and https://www.drupal.org/project/telephone_validation which provide clean solutions to this into core, as part of core support for the telephone field rather than separate modules?

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

would agree that maybe bringing in those two modules would be good for this module.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

Know this is a super old ticket and just volunteered to help keep an eye on the telephone module so going

So brought this up in slack a month ago in the #contribute channel with dpi and borisson_

Per dpi

validation should be left to contrib as local formats differ by country, subregion, even cultural preference.

I will agree on that so don't think telephone_validation could belong in core.

The libphonenumber dep is the right tool for the job. but it is so massive, and updated too often, I don’t think it belongs in core

It probably would be better to keep separate so updates can happen more often.

imo the best core should do is spit out E164, plus symbol and a string of unseparated digits. and ensure contrib can hook in properly at every opportunity

So think we can open a followup for that last quote but the rest seems to be a won't fix status.

Putting into PNMI for more thoughts.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

If still a valid bug please reopen addressing my comment in #36