Re: strip_tags
| From: | BB | Date: | Mon, 01 Jul 2002 15:40:12 +0000 |
| Subject: | Re: strip_tags | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104690@lists.php.net to get a copy of this message | ||
Well, this is the solution we are providing, I found the error to be because
word is such a wonderful program it puts XML in the middle of HTML, so I
preg'd that out and all was good again!
Thanks anyway peeps
"Analysis & Solutions" <danielc@analysisandsolutions.com> wrote in message
news:20020701153337.GA5219@panix.com...
> On Mon, Jul 01, 2002 at 04:09:04PM +0100, BB wrote:
>
> Dude, c'mon! I asked for a "_sample_" for a reason. First, I didn't want
> to have to wade through a ton of HTML. Second, it'd help you isolate the
> problem so you could formulate an accurate question and/or figure out the
> answer for yourself.
>
> If you examined where the string got cut off, you'd be able to come up
> with a short sample like this:
>
> #! /usr/local/bin/php -q
> <?php
>
> $txt = <<<sample
> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
> color=#000000><FONT face="Times New Roman">this<?xml:namespace prefix = o
ns
> = "urn:schemas-microsoft-com:office:office"
> /><o:p></o:p></FONT></FONT></P>
> sample;
>
> echo "$txt\n";
> echo
strip_tags($txt,"<STRONG><B><P><BR><TABLE><TR><TD><OL><UL><LI><IMG><A>");
> echo "\n";
>
> ?>
>
>
> The output from the sample is...
>
> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
> color=#000000><FONT
> face="Times New Roman">this<?xml:namespace prefix = o ns =
> "urn:schemas-microsoft-com:office:office"
> /><o:p></o:p></FONT></FONT></P>
>
> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">this
>
>
> So, clearly, the <?xml tag is throwing things off. The problem doesn't
> arise in the setting of $txt because echoing $txt comes through fine.
> Therefore the problem is with strip_tags().
>
> Do you want to keep the XML or strip the XML? I'm guessing you want it
> taken out. Now, it's time to ask the rest of the folks on the list:
>
> "strip_tags() is being tripped up by <?xml tags in my strings. Those tags
> cause strip_tags() to stop processing the rest of the string. I want the
> XML tags, along with all of the other unwanted HTML tags, ripped out. Is
> this a bug in strip_tags() or do I need to go about this in anther way?"
>
> --Dan
>
> --
> PHP classes that make web design easier
> SQL Solution | Layout Solution | Form Solution
> sqlsolution.info | layoutsolution.info | formsolution.info
> T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
> 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409