[pmmail-list] PMMail and HTML

J Seder pmmail-list@blueprintsoftwareworks.com
Wed, 29 May 2002 18:51:39 +0000


The good news about PMMail is that you can write a user filter that
strips HTML tags.  The following just crudely disables them and also
wrecks anything that depends on '<' by changing '<' into '_'...  It
spares message headers by waiting for an HTML tag before starting its
dirty work.

If this discussion doesn't go away then I might enhance it to more
intelligently strip them.

Save this as a file (e.g. pmunhtml.cmd) in your PMMail program
directory, and specify it as a user exit in an Incoming or Manual
filter (rexx pmunhtml.cmd).  Use at your own risk -- and it is risky. 
No warranties expressed or implied.



/* Rexx script to turn all < into _ in a PMMail message.
   This is a stupid but effective way to remove HTML tags.
   Jonathan Seder May 2002*/
call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
/* trace normal */
arg ffile
if ffile='' then do
   say 'No input argument!'
   return
   end
ifp = lastpos('\',ffile)
fpath = left(ffile,ifp)
fname = substr(ffile,ifp+1)
tempfile = SysTempFileName(fpath||'pmunhtml.???')
/* Disable HTML tags */
htmlflag = 0
do forever
   if lines(ffile)=0 then leave
   b = linein(ffile)
   /* We don't want to remove < in the header */
   if htmlflag=0 then do
      bu = translate(b)
      if pos('<HTML',bu)<>0 then htmlflag = 1
      else if pos('<p>',bu)<>0 then htmlflag = 1
      else if pos('<a ',bu)<>0 then htmlflag = 1
      else if pos('<title',bu)<>0 then htmlflag = 1
      end
   if htmlflag then do forever
      /* This loop could use some intelligence */
      i = pos('<',b)
      if i=0 then leave
      b = overlay('_',b,i)
      end
   n = lineout(tempfile,b)
   end
n = LineOut(tempfile)
err = stream(ffile,'C','CLOSE')
trace all
'erase' fpath||'eraseme.fil'
'rename' ffile 'eraseme.fil'
rename tempfile fname
return

- pmmail-list - The PMMail Dicussion List ---------------------------
To POST to the list, send your message to:
pmmail-list@blueprintsoftwareworks.com

To UNSUBSCRIBE, send a message to mdaemon@bmtmicro.com with the first 
line of the message body being...
UNSUBSCRIBE pmmail-list@blueprintsoftwareworks.com
---------------------------------------------------------------------