[Zope] structured text bug in Zope 2.4.0 warning

Peter Bengtsson mail@peterbe.com
Mon, 6 Aug 2001 12:50:33 +0200


I just posted this:
http://classic.zope.org:8080/Collector/2487/view

Basically, in Zope 2.4.0, the use of structured_text() returns little <html>
and <body> tags too.

I _had_ this working fine:
from DocumentTemplate.DT_Var import structured_text
def ShowDescription(text):
    """
    Display text, using harmless HTML
    """
    text = text.replace('<','&lt;')
    text = text.replace('>','&gt;')
    st = structured_text(text)
    # BUG in structured_text in Zope 2.4.0
    # it returns these annoying tags.
    st = st.replace('<html>','')
    st = st.replace('<body>','')
    st = st.replace('</body>','')
    st = st.replace('</html>','')
    return st


...but had to patch it to this:
from DocumentTemplate.DT_Var import structured_text

def ShowDescription(text):
    """
    Display text, using harmless HTML
    """
    text = text.replace('<','&lt;')
    text = text.replace('>','&gt;')
    return structured_text(text)


I just wanted to warn you because this is only a problem on the surface (the
HTML).
Some of my formatting looked the same when using IE, but with Opera I
noticed the difference because the structured text refused to stay center
aligned despite that I had this: <div align="center"><dtml-var
"ShowDescription(REQUEST['text'])"></div>

So, be careful if you use Zope 2.4.0, structured text. The worst that can
happen is that the HTML is so invalid that it doesn't work on some browsers.

Cheers, Peter