Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-3240

'style' attribute of <font> tag discarded when cleaning html

    XMLWordPrintable

Details

    • Unit

    Description

      I encountered this issue with the following oo generated html fragment:

      <FONT SIZE=5 STYLE="font-size: 20pt">PakData.net Online Exams</FONT>
      

      Now I don't know why OO generates such html content but what it means (in oo writer and the generated html) is that the font size is 20pt. The additional size=5 is just meant to make our lives worse I guess. Anyway, currently the DefaultHTMLCleaner does following transformation which strips off the style attribute:

      tt = new TagTransformation(HTMLConstants.FONT, HTMLConstants.SPAN, false);
      tt.addAttributeTransformation(HTMLConstants.STYLE_ATTRIBUTE, "color:${color};font-family=${face};font-size=${size}pt;");
      defaultTransformations.addTransformation(tt);
      

      Now the easiest method to fix this issue is to do the following instead:

      tt = new TagTransformation(HTMLConstants.FONT, HTMLConstants.SPAN, false);
      tt.addAttributeTransformation(HTMLConstants.STYLE_ATTRIBUTE, "color:${color};font-family=${face};font-size=${size}pt;${style}");
      defaultTransformations.addTransformation(tt);
      

      This gives the precedence to the final ${style} segment over those before it (at least on FF) and the generated XWiki 2.0 code also renders with font-size 20pt. Still, I'm not sure whether this is the right way to fix it, therefor I'm waiting for others to comment on this issue.

      Attachments

        Issue Links

          Activity

            People

              asiri Asiri Rathnayake
              asiri Asiri Rathnayake
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: