Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297900

UrlHelper does not support tel:

$
0
0

Problem/Motivation

As detected by #2484693: Telephone Link field formatter InvalidArgumentException with 5 digits or fewer in the number, PHP does not guarantee the parse_url function results for URIs.
The problem is that PHP's parse_url is 'designed' for url's not for URIs.
Because by documentation parse_url:

This function is intended specifically for the purpose of parsing URLs and not URIs.

That can lead to many issues as this function is widely used in the Core as shown in the following table:

The ones which work:

File/ClassFunction/MethodResult
core/includes/batch.inc_batch_finishedOK
core/includes/install.core.incinstall_check_translationsOK
core/includes/install.core.incinstall_retrieve_fileOK
\Drupal\Component\Utility\UrlHelperexternalIsLocalOK
\Drupal\Component\Utility\UrlHelperparseOK
\Drupal\Core\DrupalKernelinitializeRequestGlobalsOK
\Drupal\Core\Database\DatabaseconvertDbUrlToConnectionInfoOK
\Drupal\Core\Utility\UnroutedUrlAssemblerassembleOK
\Drupal\language\Form\NegotiationUrlFormvalidateFormOK
\Drupal\language\Plugin \LanguageNegotiation\LanguageNegotiationUrlgetLangcodeOK
\Drupal\language\Tests \LanguageUILanguageNegotiationTesttestLanguageDomainOK
\Drupal\language\Tests\LanguageUrlRewritingTesttestDomainNameNegotiationPortOK
\Drupal\link\Plugin\Field\FieldWidget\LinkWidgetgetUriAsDisplayableStringOK
\Drupal\menu_link_content\Entity\MenuLinkContentpreSaveOK
\Drupal\node\Tests\PagePreviewTesttestPagePreviewOK
\Drupal\search\Tests\SearchLanguageTesttestLanguagesOK
\Drupal\simpletest\BrowserTestBasegetAbsoluteUrlOK
\Drupal\simpletest\BrowserTestBasesetUpOK
\Drupal\simpletest\WebTestBasegetAbsoluteUrlOK
\Drupal\system\Tests\Form\RebuildTesttestPreserveFormActionAfterAJAXOK
\Drupal\system\Tests\Pager\PagerTesttestActiveClassOK
\Drupal\system\Tests\Pager\PagerTesttestPagerQueryParametersAndCacheContextOK
core/modules/update/update.manager.incupdate_manager_file_getOK
\Drupal\views\Plugin\views\display\PathPluginBasevalidatePathOK
\Drupal\views\Plugin\views\field\FieldPluginBaserenderAsLinkOK
\Drupal\views_ui\ViewEditFormgetDisplayDetailsOK

Not OK:

\Drupal\Core\UrlfromUriNot OK (see the issue summary)
\Drupal\Core\Validation\Plugin\Validation \Constraint\PrimitiveTypeConstraintValidatorvalidateNot OK
\Drupal\link\Plugin\Field\FieldWidget\LinkWidgetgetUserEnteredStringAsUriNot OK (it transforms tel:xxx to internal:tel:xxx)
\Drupal\link\Plugin\Field\FieldWidget\LinkWidgetvalidateUriElementNot OK (partly because of getUserEnteredStringAsUri)
\Drupal\link\Plugin\Validation \Constraint\LinkExternalProtocolsConstraintValidatorvalidateNot OK (for both tel:911 [error], tel:65536 [error] and tel:0123456789 [failure])
\Drupal\menu_link_content \Plugin\migrate\process\d6\InternalUritransformNot OK (converts the tel:xxx URL to internal:/tel:xxx)
\Drupal\shortcut\Controller \ShortcutSetControlleraddShortcutLinkInlineNot OK (converts the tel:xxx URL to internal:/tel:xxx but it's not likely to happens in shortcuts)
core/modules/system/system.modulesystem_retrieve_fileCan throw notices but not likely to be used with a tel URI

Proposed resolution

We have Drupal\Component\Utility\UrlHelper (URL). We should create a similar UrIHelper (URI) class which is a true RFC 3986 parser.

Note: An external parser can't be used with our current Drupal requirements (PHP 5.6+ or php-intl requirements, both which Drupal doesn't have now)

Wrap parse_url in a drupal_parse_uri function so we can manage all specific cases and unit test it.

Remaining tasks

Discuss, Fix PHP, Fix Drupal, Enjoy

User interface changes

None.

API changes

An added URIHelper class.

Data model changes

None.


Viewing all articles
Browse latest Browse all 297900

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>