Validate string given to _contextual_id_to_links()

Created on 24 September 2024, 7 months ago

Problem/Motivation

The contextual.module function

function _contextual_id_to_links($id)

currently uses the given $id string without validating its format.

In the implementation you see that it expects a string with

  • contexts separated by |
  • parameters separated by :

But doesn't validate the given values before they are used.

So if the format is wrong or empty parameters are simply missing, this leads to the following warning:

Warning: Undefined array key 2 in _contextual_id_to_links() (Zeile 211 in /web/core/modules/contextual/contextual.module).

but can't be debugged well.

Steps to reproduce

Provide a contextual link in wrong / unexpected / incomplete format string. For example this can happen in custom code or using modules like twig_tweak: πŸ› Notice: Undefined offset: 2 in _contextual_id_to_links() Fixed

Proposed resolution

Implement a validation for the contextual string to be correct

Remaining tasks

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

contextual.module

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024