Re: [PHP4BETA] Small patch to string.c

From: Date: Mon, 20 Mar 2000 17:28:09 +0000
Subject: Re: [PHP4BETA] Small patch to string.c
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-12437@lists.php.net to get a copy of this message
I only poked my head in this for a few seconds, but I think a better solution would be to modify htmlspecialchars() or htmlentities() to accept a list/string of characters to translate. strip_tags() should be about stripping tags and should assume that it's being passed valid HTML. -adam On Sun, 19 Mar 2000 rasmus@php.net wrote: > Ah, sorry, should have read your patch. I will have a closer look. > > On Sat, 18 Mar 2000, Peter Kovacs wrote: > > > On Sun, 19 Mar 2000 rasmus@php.net wrote: > > > > > > While this isn't extensively tested, this patch modifies strip_tags to > > > > convert > characters encountered in state 0 (the output state) into the > > > > string "&gt;". Whether or not this is entirely useful is another > > > > story. > > > > > > Hrm.. This doesn't seem like a good idea to me. If you want to convert < > > > to &lt; feed the output of strip_tags() through htmlspecialchars() > > > > I don't want to convert < to &lt; (otherwise I would just use > > htmlspecialchars like you suggest), I want to convert the > character to > > &gt; under certain circumstances (i.e. when it isn't part of a tag) Right > > now strip_tags removes these characters from its output. > > > > > strip_tags() takes an optional argument of allowable tags. Your patch > > > would render this arg useless. > > > > I just tested this and it seems to work fine: I passed the following input > > through strip_tags using "<a><b>" as the "Allowable tags" > > argument. > > > > <a href="xâ6* > > -;ܸ’Q¶úEhttp://www.knowpost.com/">KnowPost</a> > > <b>This is bold</b> > > > this has a carat in front of it. > > <i>this isn't italics</i> > > > > And it exhibits the correct behavior. > > > > I'm not saying this is necessarily desirable behavior, I added it because > > I need "lone" > characters to appear. > > > > Peter > > > > -------------------------------------------------- > > Peter D. Kovacs KnowPost.com LLC > > Lead Engineer peter@knowpost.com > > -------------------------------------------------- > > > > > > > > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net > -- / adam maccabee trachtenberg | visit college life online \ \ adam@student.net | http://www.student.com /

« previous php.version4 (#12437) next »