Log a warning if attribute names contain a space

Created on 21 March 2025, 4 months ago

Problem/Motivation

Log a warning if the attribute name contains a space and we strip the attribute all together (e.g. ['selected href' => 'http://example.com']). Because we're only checking that the output attribute names match the ones we pass in this will be stripped.

Steps to reproduce

Proposed resolution

If an attribute name contains a space log a warning and strip the attribute entirely.

Remaining tasks

If an attribute name contains a space log a warning and strip the attribute entirely.
Test coverage.

User interface changes

A warning will be logged if an attribute name contains a space.

Introduced terminology

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

TBC

📌 Task
Status

Active

Version

11.1 🔥

Component

link.module

Created by

🇺🇸United States damienmckenna NH, USA

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

Merge Requests

Comments & Activities

  • Issue created by @damienmckenna
  • 🇮🇳India arunsahijpal

    Working on it.

  • 🇳🇿New Zealand quietone
  • Merge request !11594Issue #3514612: Added logger. → (Open) created by arunsahijpal
  • Pipeline finished with Failed
    4 months ago
    Total: 107s
    #455906
  • Pipeline finished with Failed
    4 months ago
    Total: 674s
    #455970
  • 🇮🇳India arunsahijpal

    Added a logger, please check.

  • 🇺🇸United States smustgrave
  • Pipeline finished with Failed
    4 months ago
    Total: 79s
    #456222
  • Pipeline finished with Failed
    4 months ago
    Total: 125s
    #457645
  • Pipeline finished with Failed
    4 months ago
    Total: 140s
    #457672
  • 🇮🇳India arunsahijpal

    Added test,
    @smustgrave please review.

  • Hey, I am Gautham, at DrupalCon Atlanta, and I am working on testing this

  • 🇺🇸United States smustgrave

    Putting into NW as the pipeline has issues. But maybe someone from DrupalCon will pick up.

  • @arunsahijpal can you add the steps to reproduce this issue?

    Also, I noticed there is a commit related to another issue(#3514939) in this merge request, can you provide some clarification on why it was part of this merge request?

  • 🇮🇳India arunsahijpal

    Hi @grallapa2,
    As this issue in not like other issues which you can reproduce as I.S says that if you write a wrong attribute name in an element then the drupal just strips it silently without informing the user that he/she has used a wrong attribute so in order to follow a good practice we are going to log a warning before stripping the attribute.
    So I've added a logger warning and a test case to check this.

    For running this testcase you can do

    phpunit core/tests/Drupal/Tests/Core/Template/AttributeTest.php
    

    and if you want to do manual testing on your cli then you may write this

     drush php:eval ' 
      $attributes = new \Drupal\Core\Template\Attribute([
        "valid_attribute" => "value",
        "invalid attribute" => "value",
      ]); 
      dump($attributes->toArray()); 
      \Drupal::logger("debug")->notice("Attributes stored: @attributes", ["@attributes" => json_encode($attributes->toArray())]); 
    '
    

    and that issue no. mentioned in that commit is done by mistake, could you please correct it?

    Feel free to ask any other query.

    Thanks,
    Arun

  • Status changed to Needs work 1 day ago
  • 🇺🇸United States dcam

    It looks like this belongs to the theme system. If I'm wrong can the issue summary be updated with additional information about why this is relevant to the Link module?

Production build 0.71.5 2024