Since updating to the 7.x-1.8 version, editing a saved node has style tags stripped. This only appears to happen when a text format filter of "Limit allowed HTML tags" is used. It does not happen when using Full HTML. I have all security filters disabled in the ckeditor security tab, but it still strips as though it is running the filters.

This causes any changes made on a previous edit to be lost when editing the node a second time.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

segovia94’s picture

I just did a fresh install of Drupal 7.12 and installed the 7.x-1.8 ckeditor module.
I found the same results that even when deselecting all security options in the security tab the editor would filter the html on load.

Steel Rat’s picture

I think this is also what I'm seeing.

When I add a comment using full HTML and apply some text styles/formatting, the source and rich text appear as expected in the editor. Here is the source:

<p>
	<span style="font-size:18px;"><span style="font-family: comic sans ms,cursive;">Testing</span></span></p>

But when I save the text, the styles are mostly stripped and some extraneous html is displayed:

x;">Testing

Steel Rat’s picture

Ok, looks like the problem I am experiencing is due to the Smileys filter. Certain portions of the tag would be partially interpreted as a smiley.

dczepierga’s picture

Status: Active » Closed (works as designed)

Is not depend on security filters. Security filters are only called on the start when u edit page with content. When click Save button CKEditor copy content from WYSIWYG editor to textarea without any transform or security filters. So i after save sth not work u must search this in Drupal text formats filters. Not in Security Filters of CKEditor module.
When u have sth stripped on the begining of page edit then u can check Security Filters :)

I check this here without Simleys filter and for me everything works as designed. So @segovia94 pls check which filters u have in your text format configuration (which u use) and there deselect them.

If u don't understand sth or u have more questions pls open this issue (change status to active), for now i closed this issue.

Greetings

segovia94’s picture

Status: Closed (works as designed) » Active
FileSize
46.69 KB
38.8 KB
36.6 KB
35.14 KB

Thanks @dczepierga for the reply. However, I might not have explained my problem clearly. The filtered text works correctly on node view. It correctly strips the style tag. However when editing that node, the ckeditor strips the style tag on load. Ckeditor is applying the text filter to the node edit.

Without Ckeditor installed, here is the node in view using a text filter "Filtered HTML". It correctly strips the style tag.
node filtered view

When I edit the node it correctly shows the style tag in the edit box using the unfiltered text.
node filtered edit

Now I install ckeditor and turn off the security filters.
ckeditor config

When I edit the node it applies the text format on the edit screen. It adds paragraph tags and strips the style tags.
edit with ckeditor

In the 7.x-1.6 version it would not apply the text filter to the node edit.

dczepierga’s picture

Status: Active » Postponed (maintainer needs more info)

@segovia94, could u check last DEV version of CKEditor module?
Yesterday i commit new security filters policy to CKEditor module where was a lot of changes/improvements last days.
May be this help in your case, if not we will try to find the problem and fix it.

Greetings

segovia94’s picture

I updated to the latest DEV, and it looks like the text filter is no longer applied. For example, if there is an img tag that would normally be filtered out, it will appear in CKeditor.

However, the style tags are still being stripped if the text format uses "Limit allowed HTML tags."

Is it designed for security reasons to now strip style tags even if it does not strip un-allowed tags like an iframe? I realize style tags can be a security issue.

The reason I ask is because I use text filters like Image Resize Filter that will take the style tags to process an image. If the style tag is eliminated on edit it removes previous edits to the image. That is just one example.

If in fact it is working as intended, would it be possible to have an option to disable the style stripping without turning the core text filter off altogether?

Thank you for the help. It's greatly appreciated.

dczepierga’s picture

@sergovia, "Limit allowed HTML tags" always remove all attributes in tags and u cannot do anything with it - if i remember good it's only possible to change list of allowed tags and nothing else.
Try to install and use "WYSIWYG filter" module (link) instead. There is possible to configure all allowed tags and attributes.
Other security filters modules also should have that option - list of this modules u have in "Security" section on CKEditor profile page.

Greetings

Steel Rat’s picture

@dczepierga

I don't think it's correct to say that ALL attributes are stripped, but style attributes certainly are. For example, if you allow the img tag, you can use width and height attributes without them being stripped by filtered HTML.

I also recommend the WYSIWYG filter module. Just installed it yesterday and it did the trick for me to allow style sizing for the IMG tag for registered users on my site. It gives you fine control over which style attributes are allowed.

dczepierga’s picture

I'm sry I used wrong words writing that... but I think all understand what i want to write :)

Yes WYSIWYG filter module is the best to customize filtered tags and their options.

I will wait for @segovia94 confirmation that everything works now as he expect and i think we can close this issue.

Greetings

segovia94’s picture

Thanks for all the help.

Yes @dczepierga I understood what you were writing.

I actually looked into the WYSIWYG filter module a while back. It's almost perfect, but they are very strict about never allowing certain tags like iframe or embed tags. That complicates things for me on a different end.

I can't say that everything works as expected now, but that's fine. The main confusion was that in 1.6 it did not strip styles for me and in 1.8 it did.

After looking into the code I can see that the ckeditor_filter_xss() function is running...

//Call default CKEditor built-in filter
if ($name == "filter_html" && $status == 1) {
  preg_match_all("|</?([a-z][a-z0-9]*)(?:\b[^>]*)>|i", $text, $matches);
    if ($matches[1]) {
      $tags = array_unique($matches[1]);
      $text = filter_xss($text, $tags);
    }
  continue;
}

The part that is a little confusing now is that it takes all the tags currently in the text and then passes them into filter_xss() as acceptable tags. Normally, the filter_html filter would strip unwanted tags and styles.

From a security standpoint I completely understand. From a usability standpoint it's a little confusing having it detect a filter designed to strip unwanted tags and styles and then only stripping styles. If I was editing a node I would understand having my text filtered the same as when viewing it, but having only a portion of it stripped comes without much warning.

In the end, I will find a different workaround for my specific needs.

Thanks for the time and help.

emmonsaz’s picture

FYI, for anyone experiencing this with the latest CKEditor library (4.4.7), use this drop-in replacement patch: https://dev.ckeditor.com/attachment/ticket/5547/image.js

Credit: https://dev.ckeditor.com/ticket/5547

Tran’s picture

I've been having this problem for over a year.
It's frustrating.
Certain embeds (twitter) turn into "block quotes" and lose their twitter formarting.
Youtube still works.
I would love a work around.