Link field doesn't sufficiently validate input

Created on 9 January 2018, over 7 years ago
Updated 14 August 2025, 30 days ago

Problem/Motivation

Currently, In default link field we have URL and Link text.
URL field accepts multiple URLs, which leads to creating broken URL in the node view page.

e.g. I can add 2 urls same time https://www.google.com, https://www.google.in
and in node view, it comes as https://www.google.com%2C%20https//www.google.in

See attached images:

Steps to reproduce

  1. Add a Link Field to a content type allow one value
  2. Add a node of that content type and in the Link field add two Urls separated by a comma, for example, https://www.google.com, https://www.google.in.
  3. Save - notice no errors

Proposed resolution

Validate the field using UrlElement::validateUrl()

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component

link.module

Created by

🇮🇳India chintan4u Pune

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • 🇺🇸United States dcam

    I did additional testing.

    If the URL input accepts a second URL, then I think the natural next step is to wonder if it accepts any input after the URL. It does! Try entering any garbage text after a URL. It can be saved with no problem. So this issue isn't specifically about a "second URL."

    Then it follows that one should wonder "How much invalid input does this actually accept?" It turns out that you can enter anything after the URL scheme and it will pass validation.

    All this means that @quietone's instincts were initially correct and this issue is a duplicate of 🐛 Insufficient link validation for external URLs in link widget Needs work .

  • 🇬🇧United Kingdom ChrisDarke London
  • 🇺🇸United States dcam

    Granting credit to the major issue triage contributors from Amsterdam 2019.

Production build 0.71.5 2024