[Zope] Strip all HTML

Paul Winkler pw_lists@slinkp.com
Tue Aug 5 17:11:02 EDT 2003


On Tue, Aug 05, 2003 at 05:47:39PM +0200, ken@practical.org wrote:
> text = re.sub('</SCRIPT>', '-->', text)
> text = re.sub('</style>', '-->', text)
> text = re.sub('</script>', '-->', text)
> text = re.sub('</STYLE>', '-->', text)

note that for these simplest expressions, e.g. 
re.sub('</STYLE>', '-->', text) , it's equivalent (but faster)
to do text.replace('</STYLE>', '-->').  But that's a quibble.

> Dylan: The re.compile lines did not work for me.
> I'm using Zope 2.5.1 with Python 2.1.3 (Zope binary version) on FreeBSD4.3. I remember having to specifically allow importation of the re module, but perhaps re.compile needs something else?? I get a 401 and the following traceback:

(snip)
You might be right.  I'd suggest doing it as an External Method, 
then you can use all of the re module without restrictions.
The re.compile version should be cleaner and more reliable than
explicitly checking different cases.

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's THE SEISMIC GIRL!
(random hero from isometric.spaceninja.com)




More information about the Zope mailing list