Date: Mon, 15 Jun 2009 18:21:16 -0700 From: Gary Kline <kline@thought.org> To: FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG> Subject: feedback, comments on this php-delimiter scrubbing program? Message-ID: <20090616012114.GA38011@thought.org>
next in thread | raw e-mail | index | archive | help
guys, last night i was lost with a slightly shorter version of this. even looking at a printout did nothing. this morning i had another go and went in a corner and started at the code. finally i figured it out. this *seems* to work... The only thing this does is remove the "<?" and "?>" delimiters. i'll go more into my rationale later on. i'm pretty sure i can tighten up on this; getting it to work was my main goal. can any of you break this? gary Encl: dephp.c, test -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix $Id: dephp.c,v 1.6 2009/06/16 01:05:47 kline Exp kline $ #include <stdio.h> int main() { int ch; do { if ((ch = getchar()) != EOF) switch (ch) { case '>': putchar (ch); break; case '<': putchar (ch); switch ((ch = getchar()) ) { case '?': ch = getchar(); while (1) { if (ch == '?' && (ch = getchar()) == '>') { break; } else { ch = getchar(); } } break; case '>': putchar (ch); break; default: putchar(ch); break; } break; default: putchar (ch); } } while (ch != EOF); return 0; } // test foo bar <? baz ?> blah, blah < > <?lll?> blah, blah: more HERE. <> < > < > < > <?php ?>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090616012114.GA38011>