[Zope-CMF] Preventing HTML in Structured Text in Plone/CMF

Steven Hayles sh23@leicester.ac.uk
Thu, 3 Jul 2003 17:07:34 +0100 (BST)


Hi

I'd like to block the embedding of HTML in Structured Text in Plone. I can
see that I could modify CMFDefault.Document.Document._edit, replacing

  self.cooked_text = format_stx(text=text, level=level) 
            
with

  self.cooked_text = format_stx(text=html_quote(text), level=level)  

However, a monkey patch seems better. Shouldn't I be able to use the
following in an __init.py__ file in a new product?

  from Products.CMFCore import utils
  from DocumentTemplate.DT_Util import html_quote

  original_format_stx = utils.format_stx

  def new_format_stx(text, level):
    """"format_stx replacement"""
    return original_format_stx(text=html_quote(text), level=level)

  utils.format_stx = new_format_stx

Can anyone explain to me slowly and clearly why this approach doesn't work?

Steven

Steven Hayles - Computer Systems Developer, sh23@le.ac.uk
Learning Technology Section, Computer Centre, University of Leicester,
University Rd, Leicester, LE1 7RH 
Fax (0/+44)116 2525027 WWW <URL:http://www.le.ac.uk/home/sh23>