I am posting the following code :

<img alt="" src="/sites/sitename.com/files/u4/avatar.jpg" style="width: 56px; height: 56px; float: left; border-width: 1px; border-style: solid; margin: 5px 10px;" />

But after filtered by wysiwyg_filter, i get :

<img alt="" src="/sites/sitename.com/files/u4/avatar.jpg" style="width:56px; height:56px; float:left; border-width:1px; border-style:solid" />

All the available styles under "Style Properties" are ticked and "HTML Elements and Attributes is configured to :

@[class|style|title],
a[href|target|title], 
img[src|width|height|alt|title], 
em, strong, strike, del, sub, sup, i, b, q, acronym, samp, kbd, 
ul, ol, li, dl, dt, dd, 
p[align<center?justify?left?right], br, hr, 
div[align<center?justify?left?right], span, 
table[width|cellpadding|cellspacing|border], tr[align|valign], td[align|valign|width], tbody, th[align|valign|width], thead, tfoot, colgroup, col, caption, 
address, blockquote, pre, cite, code, 
h1, h2, h3, h4, h5, h6

I have tried both the 1.4 and the 1.x-dev versions and get the same behavior.

Comments

gaellafond’s picture

I have the same problem.
The style attribute is not stripped as long as it contains only one value.

Not stripped:

margin: 10px;
margin-top: 10px;
margin-right: 5px;
margin-bottom: 10px;
margin-left: 5px;

But the filter strip them when it contains more than one value. This is a W3C valid case1 that is probably not taken in consideration by the WYSIWYG Filter Style parser.

Stripped:

margin: 10px 5px;
margin: 10px 5px 10px 5px;

The same bug apply to padding, and probably other styles such as border.
List of CSS1 elements possibly affected:

font
background-position
background
text-decoration
margin
padding
border-width
border-color
border-top
border-right
border-bottom
border-left
border
list-style

1. http://www.w3.org/TR/CSS1/#box-properties
See element 5.5.5 Margin
Value: [ <length> | <percentage> | auto ]{1,4}

gaellafond’s picture

Title: inline margin style attribute gets stripped from img tag » inline style attribute gets stripped
Priority: Normal » Critical
gaellafond’s picture

StatusFileSize
new1.65 KB

The bug seems to be limited to margin and padding styles.

I made a patch but it doesn't allow 100% of valid cases. The filter will still strip margin and padding if it contains mixed values.
Example:
margin: auto 10px;

This sort of case is valid but it will be strip by the filter. Since it's not a common behaviour for a WYSIWYG editor, the patch is safe to be used.

NOTE: I made the patch for the last stable version (6.x-1.4). I didn't test is on the dev version. I will adapt it if it can not be apply.

kewlguy’s picture

subscribing

BenK’s picture

Subscribing....

kewlguy’s picture

THANK YOU!
Patch appears to work well for me, I was getting all kinds of missing string error back traces, as well as, formatting not working as expected on my site from the wysiwyg filter.

I applied the patch from #3 post, as well as, the patch from "Filter form validate and submit handlers overwritten" and all is real good!

My filter is working excellent now!

Drupal-6.16
A gazillion modules
Apache version 2.0.63
PHP version 5.2.12
MySQL version 5.0.90-community

gaellafond’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new1.68 KB

I made the patch from copy of files and I forgot to correct the paths in the header. The patch will be more easy to apply like this.

markus_petrux’s picture

Priority: Critical » Normal
Status: Patch (to be ported) » Needs review
StatusFileSize
new3.3 KB

Could you please try this patch instead?

rggoode’s picture

subscribing

gaellafond’s picture

Excellent!
Thanks markus_petrux for your patch. You moved only one parenthesis and it solved the problem. It event allow the case with mixed values such as margin: auto 10px;. I tested it with many cases and it's seems to be perfect.

margin: 100px; => SUCCESS
margin: auto 10px; => SUCCESS
margin: 10px 100px 10px 100px; => SUCCESS
margin: 10px     auto 10px 100px; => SUCCESS
margin: 10px     auto 10em 100%; => SUCCESS

margin: 10px 100px 10px 100px 10px; => FAILED (as expected)
margin: 10px 100px10px 100px; => FAILED (as expected)
margin: 10xe; => FAILED (as expected)
margin: 100pi; => FAILED (as expected)

I think this patch is ready to be ported.

markus_petrux’s picture

Title: inline style attribute gets stripped » margin/padding style attribute gets stripped when using more than one value
Status: Needs review » Fixed

Sweet. Committed path in #8 to CVS. Thanks for reporting the issue and the feedback provided.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.