beta5 breaks filter

Created on 26 January 2024, 10 months ago
Updated 5 July 2024, 4 months ago

The change in 🐛 Does not work with ckeditor 5 Fixed breaks the filter function when you are not using an editor like CKEditor in your text format.

I have the following text format that no longer works after updating to beta5. Downgrading to beta4 solves the issue.

uuid: 2223de04-7710-4620-8144-4a1908ea1962
langcode: en
status: true
dependencies:
  module:
    - soembed
name: oEmbed
format: oembed
weight: 0
filters:
  filter_soembed:
    id: filter_soembed
    provider: soembed
    status: true
    weight: -49
    settings:
      soembed_maxwidth: '780'
      soembed_replace_inline: '0'
      soembed_allowed_buckets: {  }
🐛 Bug report
Status

Needs review

Component

Code

Created by

🇸🇪Sweden peter törnstrand

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

Comments & Activities

  • Issue created by @peter törnstrand
    • Ki committed 47084194 on 8.x-2.x
      Issue #3417152: beta5 breaks filter
      
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States Ki

    It was not easy to find regex to handle different scenarios. Pushed the fix in the release 8.x-2.0-beta7.

  • 🇸🇪Sweden peter törnstrand

    Still having issues with this using beta7, if I change the regexp to #([^"])?(https?://[^\s<]+)([^"])# it works. Made the first match capturing group optional.

  • 🇺🇸United States Ki

    We'd need to come up with a regex that works with ckeditor 4, ckeditor 5, and no editor. Will the suggested fix satisfy it?

  • 🇸🇪Sweden peter törnstrand

    Sorry for late reply. I have not tried it beyond my own use case. I will test and report my findings.

  • Status changed to RTBC 9 months ago
  • 🇸🇪Sweden peter törnstrand

    Yes, the pattern #([^"])?(https?://[^\s<]+)([^"])# works for all three cases.

    • Ki committed d4a05f35 on 8.x-2.x
      Issue #3417152 by Peter Törnstrand: beta5 breaks filter
      
  • Status changed to Fixed 9 months ago
  • 🇺🇸United States Ki

    Applied the fix.

    This is almost identical to the pattern for `Replace in-line URLs` option, though. Now I wonder if I should get rid of the option, which is getting irrelevant.

  • 🇺🇸United States loze Los Angeles

    This now fails for me when using no text editor and there are no characters following the url, see screenshot

    This patch fixes it for me.

  • Status changed to Needs review 9 months ago
  • 🇺🇸United States loze Los Angeles
    • Ki committed 1d1437e0 on 8.x-2.x authored by loze
      Issue #3417152 by loze, Peter Törnstrand, Ki: beta5 breaks filter
      
  • 🇺🇸United States Ki

    Peter Törnstrand

    I've applied loze's patch and pushed to the latest 8.x-2.x-dev version.

    Could you it works for you?

    Thanks.
    Ki

  • Status changed to Needs work 8 months ago
  • 🇺🇸United States loze Los Angeles

    After further testing testing these latests commit, the regex still fails in a few places

    in particular the url inside the tag gets converted to a video in the following example.
    <a href="https://www.youtube.com/watch?v=CsGQOPLGImA">https://www.youtube.com/watch?v=CsGQOPLGImA</a>

    Also some urls that do not have an enabled provider are mangled. for example:
    the website <a href="https://drupal.org"><em>Drupal</em></a>
    displays broken html, see screenshot

  • Status changed to Needs review 8 months ago
  • 🇺🇸United States loze Los Angeles

    I think is regex should work
    '#(<p>|\n|^)(https?://\S+)(</p>|\n|$)#'

    This works with ckeditor and without in my testing when urls are on their own line.
    It also works for Peter Törnstrand's use case when it is the only text in the textarea.

  • 🇺🇸United States loze Los Angeles

    the regex in #16 still failed in some cases. Try this one, It seems to work.
    '#(<p>|\n|^)?(https?://[^\s<]+)(</p>|\n|$)?#'

  • 🇺🇸United States Ki

    It seems one regex that works for one easily breaks another. I'll try to find time to do tests, but I'd appreciate those in the thread test their case and work together to come up with a regex that works for all cases. Or is that actually possible? Should we introduce a checkbox setting to handle ckeditor5 as an exceptional case? Since ckeditor5 merges all lines into one in the backend, it is essentially no different from the option setting "Replace in-line URLs"

  • 🇺🇸United States mortona2k Seattle

    The links on my site broke after enabling this module.

    I'm using the "Convert urls into links" filter, and this is causing them to render with broken html.

    I think this meets the criteria for a major bug. https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

  • 🇺🇸United States Ki

    Attempt to support ckeditor 5's behavior of saving content source in one line caused too much trouble. The behavior existed for a while and seems to have gone now.

    I have reverted the regex back to old simple one. Instead, I've revised the regex for in-line URL option and updated the description for the "Replace in-line URLs" checkbox to "Recognize in-line URLs. Enable too if the wysiwyg editor saves the content source in one line."

    The update has been released in beta-9 version for review and testing.

    @mortona2k
    If you are a new user of the module, please make sure that the filter for "Convert URLs into links" comes after. As mentioned in README, the order of filters is important for the soembed filter to work.

    Thanks.

Production build 0.71.5 2024