VideoEmbedWysiwyg::getValidMatches() does not detect two videos next to each other

Created on 29 June 2023, over 1 year ago
Updated 26 September 2023, about 1 year ago

Problem/Motivation

We noticed that when adding two videos on the same line in the HTML, the filter would not replace them.

Steps to reproduce

Add something like this to the HTML:

<p>{"preview_thumbnail":"/sites/default/files/styles/video_embed_wysiwyg_preview/public/video_thumbnails/B54L7ABWCrA.jpg?itok=7tr1jHG3","video_url":"https://youtu.be/B54L7ABWCrA","settings":{"responsive":true,"width":"854","height":"480","autoplay":false},"settings_summary":["Embedded Video (Adaptatif)."]}</p><p>{"preview_thumbnail":"/sites/default/files/styles/video_embed_wysiwyg_preview/public/video_thumbnails/MGJw7yOblDE.jpg?itok=S9CqaOKh","video_url":"https://youtu.be/MGJw7yOblDE","settings":{"responsive":true,"width":"854","height":"480","autoplay":false},"settings_summary":["Embedded Video (Adaptatif)."]}</p>

Because it is greedy, the regex in VideoEmbedWysiwyg::getValidMatches() captures this as one single group.

Proposed resolution

The regex should be ungreedy and should probably look for the first closing </p>.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇫🇷France prudloff Lille

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

Comments & Activities

Production build 0.71.5 2024