Re: [PHP4BETA] Small patch to string.c
| From: | Peter Kovacs | Date: | Mon, 20 Mar 2000 17:42:25 +0000 |
| Subject: | Re: [PHP4BETA] Small patch to string.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12439@lists.php.net to get a copy of this message | ||
That's probably true, but for what I'm using it for (which, admitedly is
rather special purpose) it won't work. Basically what I'm doing is
creating the > characters like you see below for a web-based email type
application. Some HTML is allowed and so strip_tags is used to get rid of
the input that is used.
If I were then to run the output through htmlspecialchars (or
htmlentities) I would lose the HTML portion of the text, but all I want is
to convert those lone > characters into >. I could probably do this
through a regex, but this change makes it a whole lot easier for me.
I guess I just might have to live with keeping track of my changes to the
tree.
Peter
On Mon, 20 Mar 2000, Adam Trachtenberg wrote:
> 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 ">". 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 < feed the output of strip_tags() through htmlspecialchars()
> > >
> > > I don't want to convert < to < (otherwise I would just use
> > > htmlspecialchars like you suggest), I want to convert the > character to
> > > > 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="http://www.knowpost.com/",ti„g'P
> > > cÊÁñЙwÄ>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/üc>wÁ€,!ƒXëa
> > I>
> > 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 /
>
>
--------------------------------------------------
Peter D. Kovacs KnowPost.com LLC
Lead Engineer peter@knowpost.com
--------------------------------------------------