fckeditor keeps stripping away my inline css!
debonator - August 15, 2008 - 06:56
| Project: | FCKeditor - WYSIWYG HTML editor |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
i've had to use some inline css on a handful of pages to hide things like the "submitted by" info. (you don't need that on a static page). ever since i updated to the newest release of this module, fckeditor has been stripping this css from my code. needless to say, it's driving me crazy. it's fine when i first code the css, but if i need to edit the page for any reason, the editor strips it away.
help!

#1
FCKeditor module has nothing to do with this.
Anyway, I believe that you probably might have added your own settings to the fckeditor.config.js (or fckconfig.js) which were lost when you upgraded the FCKeditor module or the editor.
I cannot reproduce this isse on a fresh installation: Drupal 6.4 (Garland theme, no other additional modules) + FCKeditor 6.x-1.3-rc1 + FCKeditor 2.6.3.
Tested on FF 2 and IE 6 / Win XP+SP3.
I tried this HTML code
<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p><p><style type="text/css">p {color: blue;}</style></p>
<p>test</p>
#2
it strips this sort of css away
insert css here
and it only does this when i view source, make changes, save, and then edit again. the second time i hit view source, the css is gone.
very irritating.
#3
sorry, forgot the code tags:
<style>insert css here
</style>
#4
Is this css gone when you view source of your site or when you switch FCKeditor from WYSIWYG mode to Source mode? Did you configure your input formats properly?
Can you post here a sample code before stripping CSS code and after that?
#5
#314989: Losing Styling in Edit Mode marked as a duplicate. Ok, it's rather critical :-)
Please provide me a code samples before and after saving.
#6
hey there,
it happens when i switch from wysiwyg to source mode (which i do whenever i need to add css). i add the css like this:
<style>insert css here
</style>
hit save and everything's fine. then, without fail, i realize i need to add more css. click edit, view source, and the css is gone. it's being replaced by
<p>&npsp;</p>i've started saving the css into a text file so i can just cut and paste it back in, but it happens just about every time. i'm pretty sure i've configured everything correctly, and i'm an admin so i use full html when adding content.
any ideas?
#7
I'm having a very similar issue. Although it appears it only just started recently. My problem is with moving paragraph tags.
So, I need text to wrap around image I enter this in html:
<div id="salon"><div id="copy">
<p><img align="left" alt="salon program" src="images/salon.gif" style="margin-right: 12px;" />
<h3>Header</h3>
Copy here.
</p>
<p>Copy here.</p>
</div>
</div>
I save and get:
<div id="salon"><div id="copy">
<p><img align="left" style="margin-right: 12px;" src="images/salon.gif" alt="salon program" /></p>
<h3>Header</h3>
Copy here.
<p> </p>
<p>Copy here.</p>
</div>
</div>
#8
@mikeymh - placing H3 inside of paragraph is simply invalid, instead of trying to convince editor to stick with invalid code, just make it the right way.
@anyone - I need code samples, just like mikeymh posted above... anyone?
#9
i'd post another code sample if i could, but the one above is exactly what's happening to me. i put the css right at the top, save, hit view source again, and it disappears. this only happens if i view source. if i just use the editor, it's fine.
ideas?
#10
I'm having this issue as well. I will post a full report with code from in the editor before saving, the node code which is rendered, and the code which appears in FCKeditor after re-edit later today.
#11
HTML code I paste into the editor while "source" is active:
<div style="border: 1px solid black; width: 600px; position: relative; background-color: rgb(204, 204, 204);" class="mtgodeck">
<div style="background-image: url(http://puremtgo.com/userfiles/image/decktops/bg.png); padding-bottom: 10px; background-repeat: no-repeat; position: relative; height: 40px;" class="deckheader">
<div style="font-size: 25px; left: 3px; position: absolute; top: 3px;" class="deckname">Rock</div>
<div style="font-size: 14px; left: 5px; position: absolute; top: 28px;" class="deckformat">We Rock the Bod</div>
</div>
</div>
The same code is there after a toggle and un-toggle of the "source" button.
Code that is rendered for node when I save (surrounded by my theme code, of course):
<div style="border: 1px solid black; width: 600px; position: relative; background-color: rgb(204, 204, 204);" class="mtgodeck"><div style="background-image: url(http://puremtgo.com/userfiles/image/decktops/bg.png); padding-bottom: 10px; background-repeat: no-repeat; position: relative; height: 40px;" class="deckheader">
<div style="font-size: 25px; left: 3px; position: absolute; top: 3px;" class="deckname">Rock</div>
<div style="font-size: 14px; left: 5px; position: absolute; top: 28px;" class="deckformat">We Rock the Bod</div>
</div>
</div>
When I click 'edit', this code shows up in the FCKeditor's 'source' view:
<div class="mtgodeck"><div class="deckheader">
<div class="deckname">Rock</div>
<div class="deckformat">We Rock the Bod</div>
</div>
</div>
I did discover something strange about this though - it does not happen with my user 1, only one with lowered privileges. It is possible that it is related to input formats? I will investigate more.
#12
More information I discovered this morning:
The filtering happens in the ahah callback to fckeditor/xss, which filters the input based on the FCKeditor filters which are supposed to be set in the fckeditor settings. The code that hooks onto to the form adds the filters to the editor area. For some reason, the fckeditor is not seeing any of the filters which are set, and is always using the default filter for any area ('filter/0/1') which passes all text through the filter_xss function, stripping out the style="" attributes.
I'll investigate more later today.
#13
@jamuraa - which input format is assigned to the node which is edited and what are your security settings in the FCKeditor profile?
#14
I have a custom input format assigned to the node, with a simple custom filter which doesn't munge any of the style stuff.
It doesn't matter what my security settings are in FCKeditor profile, putting any of them on doesn't change the fact that it is only filtered by 'filter/0/1' every time if you are a non-admin user. I suspect it may be because there is no 'input formats' element in the form to detect if you are only allowed one input format.
#15
I ended up fixing this issue by making more than one filter type available to my users. When I enabled it so the filter block showed up on the page, suddenly the filtering worked exactly as expected. So a condition to repro for me was to have only one active input format for the content type (I'm using the filter by node type module so that comments have a different type than content)
#16
@jamuraa - the original issue was found in rc1 where xss filter didn't exist, so it's definitely a separate prolem. I did manage to reproduce it and I don't think it will be easy to fix (I hope I'm wrong), I have created a separate ticket here #375223: Default XSS filter is always executed if filter by node type is enabled and only one input format is available.
#17
Can this be resolved by deactivating fckeditor? I'm also set to full html.
#18
i still dont have a permanent solution for this but for the mean time, i have disabled fckeditor's stripping actions by doing the following steps:
> go to the FCK Editor module's settings
> edit the profile you are currently using
> in the SECURITY Settings, disable HTML filter.
I know there would be possible security issues here but while there are no patches yet for this problem, i would have to stick with this solution for the mean time.
~ Rei (+.0)
P.S. i also am using filtered HTML in drupal but i think its okay. the problem is in the module, or so i think.
#19
Yeah I'm having the same problem over here.
One solution I could think of is to tie the activation of FCK to the input filter. The WYSIWYG module does this (I was using it previously) and it makes it possible to set the input filter to PHP, for example, and have the editor never pop up in future sessions. As far as I know, this is not possible with FCK. If it is, let me know. :)
#20
#21
I was having a similar problem wherby the inline style was firstly not showing (fixed by diasbling the HTML filter for FCKEditor) and then not displaying (fixed by disabling the HTML filter for the FULL HTML Filter under site configuration >> Input Formats)
#22
I had a similar issue, but interestingly - only in the teaser. I would insert an image and style it using the "advanced" tab and then the style field. The body portion would retain the style, but FCKEditor would strip the style from the teaser. I disabled the FCKeditor "HTML" filter, which solves the problem, but only for a profile I trust.