TTW Html Filtering being reset on upgrade to 4.3.18

Hi there,

When test upgrading from Plone 4.3.14 to 4.3.18, all the changes made via the HTML Filtering controlpanel are being reset. Subsequently, when we load a page with offending nasty tags or stripped tags, our existing code is being erased/stripped. We can get around it by upgrading and then restoring our settings by hand via the HTML Filtering controlpanel, but we're dealing with over 100 websites would prefer to prevent this from happening altogether if possible.

Thanks!

1 Like

Hi There. I hope I can help.

You found a bug... a old bug noone cared about enough to work on:
https://web.archive.org/web/20131026035512/https://dev.plone.org/ticket/12785

We have a home cooked solution that stores the html filtering data in 'portal_transforms.xml' and adds the import/export to generic setup profiles - allowing you to save those settings in a Generic Setup way. Unfortunately, our Plone 4 build on github is MARKED PRIVATE (I grumble at management....) But I'll do my best to share the components and steps.

What we accomplish here is creating a Generic Setup step for Portal Transforms to import and export these data from/to your GS Profile.

This stuff should really be in Products.PortalTransforms but we never asked for it to be pulled in:
( points finger at @tseaver )

Good reading about what we are doing here: https://productsgenericsetup.readthedocs.io/en/latest/handlers.html

Step 1: add an export step to your export_steps.xml

 <export-step id="transforms" handler="Products.rfasite.setuphandlers.exportPortalTransformsTool" title="Transforms">
  Export portal_transforms tool settings.
 </export-step>

step 2: Add an import step to your product in your import_steps.xml

 <import-step id="transforms" handler="Products.rfasite.setuphandlers.importPortalTransformsTool" title="Transforms">
  <dependency step="toolset"/>
  Import portal_transforms tool settings.
 </import-step>

These make the steps appear in your ZMI under portal_setup.

Put the code behind it in YOUR setuphandlers:

https://pastebin.com/DPcipFpJ

Next: run your export from the ZMI on your older plone instance to generate the portal_transforms.xml file. It will have lots of stuff in it, but specifically your html filter tag settings:

<?xml version="1.0"?>
<object name="portal_transforms" meta_type="Portal Transforms">
 <property name="title"></property>
 <transform name="html_body"
    module="Products.PortalTransforms.transforms.html_body"/>
 <transform name="html_to_plone_outputfilters_html"
    module="plone.outputfilters.transforms.html_to_plone_outputfilters_html"/>
  .... snip ... 

  <nasty_tag long="1" tag="applet"/>
  <nasty_tag long="1" tag="meta"/>
  <valid_tag long="1" tag="a"/>
  ....
  <valid_tag long="1" tag="var"/>
  <valid_tag long="1" tag="video"/>
 </transform>
  ....
</object>

Oy hey, yeah, add the adapter defined in (the pastebin) to your configure.zcml -

  <adapter
      factory=".setuphandlers.PortalTransformsToolXMLAdapter"
      provides="Products.GenericSetup.interfaces.IBody"
      for="Products.PortalTransforms.interfaces.IEngine
           Products.GenericSetup.interfaces.ISetupEnviron"
      />

Now, do your upgrade.

A manual step now - go back to the ZMI, choose your profile and import the Portal Transforms Tool.

I guess you could add an upgrade step to accomplish this too, if you didn't want to visit the ZMI for each website to export and import.

I hope this is some use to you. Wish there was a better answer.

If you (or anyone) want to go through the hoop - post your github username and I'll add you to https://github.com/RadioFreeAsia/Products.rfasite so you can see the full implementation.

I missed a step.

You won't see a "Transforms" / "Export portal_transforms tool settings" in your zmi until you re-import the generic setup profile you added the import_steps.xml and export_steps.xml to.

Can't edit the post - it's too old.


In Plone 5.1, the nasty_tags and valid_tags are configured through the plone registry, instead of being tacked on to the portal_transform safe_html transform. That way, you can export your plone registry instead of running through the hoops I showed you above.

Plone Foundation Code of Conduct