This issue is in reference to this issue, but a little different so i wanted to make another issue to track it.

In the other issue the problem was coming from the [embed] tag, however what I'm up against is the filter picking up the URL without the embed tag. The issue is that WYSIWYG always place a

tag on any new line. Since the function below is only looking for a patttern that matches http it rejects the string as a pattern match.

While its not idea for the module at large, is there anyway I can check for the pattern along with

to ensure that it always gets read and converted?

function oembed_filter_oembed_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
  if ($filter->settings['autoembed']) {
    $pattern = '|^\s*(https?://[^\s"]+)\s*$|im';
    $text = preg_replace_callback($pattern, 'oembed_preg_auto_replace', $text);
  }
  return $text;
}
CommentFileSizeAuthor
#3 oembed-support_raw_urls.patch750 bytesdman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Media Crumb’s picture

Not sure if this is a good idea but i added the following to the function to strip out p tags

$text = preg_replace('/<p\b[^>]*>(.*?)<\/p>/i', '$1', $text);

function oembed_filter_oembed_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
  if ($filter->settings['autoembed']) {
    $text = preg_replace('/<p\b[^>]*>(.*?)<\/p>/i', '$1', $text);
    $pattern = '|^\s*(https?://[^\s"]+)\s*$|im';
    $text = preg_replace_callback($pattern, 'oembed_preg_auto_replace', $text);
  }
  return $text;
}
Media Crumb’s picture

Well that doesn't work. Since I'm basically removing all the p tags from the text. Anyone have a solve for this?

dman’s picture

FileSize
750 bytes

I actually did this today.
I didn't push it back here at the time, because I'm confused about what the game plan is for #2269433: Support URLs on a line by themselves in ckeditor/WYSIWYG

But I needed something that just works for us for now.

bennos’s picture

your patch is wrong. you try to patch oembed.module file but the function is in oembed.filter.inc

dman’s picture

Status: Active » Needs work

I'm sure what you mean to politely say is:

The location of some of these functions seems to have moved during some refactoring that happened earlier this year and now this quick fix needs a re-roll - if it's still needed.

bennos’s picture

yeah, sorry.

Was a little bit frustrated and so diplomatic yesterday.