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:".
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3414096-support-mailto-to-url-hook-pattern-beta4.patch | 1.09 KB | martygraphie |
Issue fork ui_suite_dsfr-3414096
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
martygraphie commentedComment #4
martygraphie commentedComment #5
martygraphie commentedI'm adding a temporary patch so that the modification will work on version 1.0.0-beta4 (based on version 1.9 of the DSFR)
Comment #6
pdureau commentedHi Martygraphie,
Thanks for the MR.
Just a question, why not using UrlHelper::setAllowedProtocols()?
For information, those preprocess hooks are useful fow now and it is great you are fixing them, but they will not stay, because they are forbidden by SDC Core API, so by incoming UI Patterns 2.x.
Comment #7
pdureau commentedMaybe because mailto protocol doesn't work with UrlHelper which expects
:/instead of just:I will merge
Comment #9
pdureau commented