Markup having new lines in <drupal-entity> tags not matched

Created on 10 July 2024, 5 months ago

Problem/Motivation

After test running the convert_entity_media_embed_entities queue dev environment content, a database search revealed one field value with a <drupal-entity> tag that was not converted to media. Investigation revealed that the value in question had a new line "\n" character within the tag markup. New lines are not matched by the /<drupal-entity(.*)data-entity-type="media"(.*)>(&nbsp;)?<\/drupal-entity>/ regular expression pattern.

Not sure whether having a new line in this markup is an edge case or unexpected user input at some point.

Steps to reproduce

  1. Edit any existing field value with media embedded with Entity Embed <drupal-entity> tags.
  2. Add a new line anywhere inside the open tag either between 'drupal-entity' and 'data-entity-type="media"', or 'data-entity-type="media"' and '>' of the open tag.
  3. Save the entity with these changes.
  4. Install module and run queue to completion
  5. Confirm that the changed field value was not converted to drupal media tags

Proposed resolution

Change the pattern to include 's', so that '.' matches new lines. In doing this, the pattern also needs to be changed to not be greedy: '/<drupal-entity(.*?)data-entity-type="media"(.*?)>(&nbsp;)?<\/drupal-entity>/s'

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

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