stripBadHTML bug - well kinda

Mike Gifford <[email protected]> 19 Jul 2003 15:22:59 -0400
Newsgroups gmane.comp.cms.phpslash.devel
Organization OpenConcept Consulting http://www.openconcept.ca
Message-ID <[email protected]>
Hello,

The bug with stripBadHTML is that it doesn't manage one user error that
a client of mine stumbled across.

<br><a href="link>1missing last</a> - Missing the last quote here
<br><a href="link">2fine</a> - Messes up this quote here

I'm not the best at regular expressions, but I would think that it would
be possible to check that both ""'s are present:

   $str = eregi_replace("<a([^>]*)href=\"?([^\"]*)\"?([^>]*)>",
                         "<a href=\\2>", $str);

It's waiting for the final " (which in this case the user forgot).

It should look for either the final " or a final > (whichever comes
first).  I would think that this would do it:
	
   $str = eregi_replace("<a([^>]*)href=\"?([^\"]*)[\"|>]?([^>]*)>",
                         "<a href=\\2>", $str);

But I haven't gotten it to work just right...

I know this isn't something that many folks are likely to do, but for
this type of interface it's good to correct simple typos if you can..

Mike
-- 
Mike Gifford, OpenConcept Consulting
Free Software for Social Change -> http://www.openconcept.ca
Site Launch - Make Every Vote Count - http://www.fairvotecanada.org
The cruelest lies are often told in silence. -- Robert L Stevenson




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0