Active
Project:
Drupal core
Version:
main
Component:
link.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Dec 2020 at 02:50 UTC
Updated:
25 Nov 2025 at 14:41 UTC
Jump to comment: Most recent
This meta is for making sense of the many issues related to link and Url validation and making a plan to fix those issues.
Following is a list of issues gathered from following related issues of #3151047: Expand LinkWidget test coverage and web searches, some of these are for Drupal 7. They are split into two loose groups, ones that focused on validation and one that adds features and validation.
Validation:
Add features:
Other:
Drupal 7 only
This all began from Bug Smash Initiative work #3151047: Expand LinkWidget test coverage.
- more to add -
TBD
Comments
Comment #2
quietone commented#295021: Expand/augment UrlHelper::isValid() to improve correctness and handle more URL types
for Drupal 7. The list of valid and invalid URLs is not as extensive as the list in #3151047: Expand LinkWidget test coverage which was obtained from
https://cran.r-project.org/web/packages/rex/vignettes/url_parsing.html. Therefor it does not offer anything for a Drupal 8 solution. I don't know about Drupal 7, so leaving as is.
#1657886: Filter "Convert URLs into links" doesn't support multilingual web addresses
For Drupal 7. TBD
#1783278: Scheme-relative URL rejected by validation
This is adding support for scheme-relative URLs
#2474191: UrlHelper::isValid() should handle hyphens, '-', correctly
This patch adds code to tests for one case, URLs with '-' in the wrong place.
Need to check this with the current list and determine if any of these need to be added. see #3151047: Expand LinkWidget test coverage
#2646744: \Drupal\Core\Url does not accept root-relative (file) URLs, making it impossible to let LinkGenerator create root-relative file URL links
This is about files
#3045484: Add support for Internationalized Domain Names (IDN)
Compare the checks done in this issue with the changes done in #3151047: Expand LinkWidget test coverage
#2215915: Support scheme-relative URLs
For Drupal 7. TBD
#389278: Create IDN encoding and decoding functions
This task has been created as a central place to develop the IDN/Punycode encode and decode functions.
#2031149: Add support for additional protocols in Link field definition
Provides ability to add custom protocols.
#2652236: Insufficient link validation for external URLs in link widget
Suggests adding validation for punycode and magnet links in /core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator and using Symfony Url Validator.
#2691099: Improve external URL validation in many ways
Suggests adding validation for punycode, protocol relative URLs, and using symfony UrlValidator.
Edit: Fix an issue number, s/33/3/
Comment #3
quietone commentedThere are two issues suggesting the use of Symfony UrlValidator. That looks like a topic for one issue, to decide if that should be used.
Comment #4
quietone commented#2474191: UrlHelper::isValid() should handle hyphens, '-', correctly These values shown in the previous comment are not checked in LinkItemUrlValidationTest
Comment #5
quietone commentedThese seems to duplicates. #1783278: Scheme-relative URL rejected by validation has more recent work, yet in 2014 sun said, 2195983-#14, that #2195983: Support scheme-relative URLs is preferred for reasons explained in that comment. Need to examine both patches further.
Comment #6
quietone commentedFound another similar issue. #2935307: Link field doesn't sufficiently validate input
Comment #7
quietone commented#3045484: Add support for Internationalized Domain Names (IDN) - is using the Symfony Url validator in UrlHelper.
Comment #8
quietone commentedComment #9
quietone commentedComment #12
quietone commentedFound another issue to add to this meta
Comment #16
liam morlandAdded #3441637: Separate out validation in Url::fromUri().
Comment #17
dcam commentedPHP 8.5 introduces a new always-available Uri extension for parsing and manipulating URIs. Ref:
It's possible that we may be able to replace some of our custom URL parsing and validation with the new extension. This could start during the Drupal 12 lifecycle if we maintain our policy of requiring the most recently released version of PHP. My hope is that it would allow us to close many of these issues that remain open.
As the Link module maintainer this effort would impact the work that I'm doing. So I'm willing to take the lead on the project.