User tests: Successful: Unsuccessful:
Pull Request resolves #37029.
The "URL" custom field (plugins/fields/url) lets an admin restrict the allowed scheme(s) via the schemes parameter, but that parameter was never actually read anywhere in the plugin code. When mailto is chosen as the only allowed scheme, the admin still has to type the mailto: prefix manually into the value - otherwise UrlFilter forces a http(s) scheme onto the value or resolves it as a path relative to the site root (e.g. https://example.com/firstname.lastname@example.com). If the prefix is typed manually as a workaround, it then shows up as visible link text on the frontend when "Show URL" is enabled.
This PR treats a field configured with mailto as the sole allowed scheme as a plain e-mail address field:
plugins/fields/url/src/Extension/Url.php: validates the raw input as an e-mail address (validate="email") and stores it raw (filter="raw"), so no scheme/host gets implicitly prepended.plugins/fields/url/tmpl/url.php: builds the mailto: link itself from the raw value at render time, and strips any legacy manually-typed mailto: prefix from both stored value and displayed text, for backwards compatibility with existing data saved under the old (broken) behavior.mailto: prefix) into the field, and save - it should save without a validation warning.mailto: link, and (if "Show URL" is enabled) the displayed text should be the plain e-mail address, without a mailto: prefix.mailto: prefix (the previously documented workaround) continues to render correctly, with the prefix stripped from the displayed text.Setting "Allowed Schemes" to only mailto had no effect on validation or storage. A plain e-mail address entered into the field would fail URL validation. The only working approach was to manually type the mailto: prefix, which then also appeared as visible link text on the frontend when "Show URL" was enabled.
A field restricted to the mailto scheme validates and stores a plain e-mail address correctly. The frontend renders it as a working mailto: link, and with "Show URL" enabled the displayed text is the plain e-mail address, without any mailto: prefix. Data previously saved with a manually-typed prefix (the old workaround) still renders correctly.
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End Plugins |
@Freewindrider Please respect our pull request template. You gave removed parts of it in your PR description, e.g. the reference to the Generative AI policy with the checkbox to acknowledge that you have read it, or the actual result (i.e. without the PR) and the expected result (i.e. with the PR)..
Please add that back to your PR description and confirm the Generative AI policy.
Thanks in advance.
Glad to see this - I needed it last week
| Labels |
Added:
PR-5.4-dev
|
||
Retested successfully with the proposed code-optimization (second commit).
@richard67 Please excuse for not having followed the template close enough. I beg you pardon for this is my first PR ever.
@Freewindrider Thanks for your PR. Meanwhile we have discussed it in the CMS Maintenance Team and cam to the conclusion that it is not really a bug fix but an improvement, so it should be made for the 6.2-dev branch. See also here: #48080
Could you rebase this PR to 6.2-dev? If not, let me know if I can help with that.
Thanks in advance.
@Freewindrider Please respect our pull request template. You gave removed parts of it in your PR description, e.g. the reference to the Generative AI policy with the checkbox to acknowledge that you have read it.
Please add that back to your PR description and confirm the Generative AI policy.
Thanks in advance.