[beta6] The url field of the button/link pattern does not support mailto and causes a 500 error

Created on 11 January 2024, 10 months ago
Updated 20 February 2024, 9 months ago

Problem/Motivation

Hi,
On drupal, a link type field can be used to enter an internal or external url and mailto.

By default the resitution is done correctly, however ui_suite _dsfr declares the hook ui_suite_dsfr_preprocess_pattern_button & ui_suite_dsfr_preprocess_pattern_link & ui_suite_dsfr_preprocess_pattern_footer_menu which checks whether the url is internal or external in order to apply certain attributes.

Except that mailto doesn't work with the verification of UrlHelper::externalIsLocal() and results in the following error 500 when the url starts with mailto :

InvalidArgumentException: A path was passed when a fully qualified domain was expected. in Drupal\Component\Utility\UrlHelper::externalIsLocal() (line 305 of core/lib/Drupal/Component/Utility/UrlHelper.php).

ui_suite_dsfr_preprocess_pattern_button(Array, 'pattern_button', Array)
call_user_func_array('ui_suite_dsfr_preprocess_pattern_button', Array) (Line: 285)

Steps to reproduce

1) Add a link-type field to an entity
2) Map the field to the button pattern
3) Create a content and enter mailto:nam@exemple.fr in the link url field.
4) Display the result on the page
5) See the 500 error

Proposed resolution

I recommend adding a check to the conditional of the ui_suite_dsfr_preprocess_pattern_button hook, which will ignore urls starting with a "mailto:".

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇷🇪Réunion Martygraphie Saint-Denis (Réunion)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024