Date: Mon, 15 Jun 2009 18:57:45 -0800 From: Mel Flynn <mel.flynn+fbsd.questions@mailing.thruhere.net> To: freebsd-questions@freebsd.org Cc: Gary Kline <kline@thought.org> Subject: Re: feedback, comments on this php-delimiter scrubbing program? Message-ID: <200906151857.45945.mel.flynn%2Bfbsd.questions@mailing.thruhere.net> In-Reply-To: <20090616012114.GA38011@thought.org> References: <20090616012114.GA38011@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 15 June 2009 17:21:16 Gary Kline wrote: > Encl: dephp.c, test case '?': ch = getchar(); while (1) { if (ch == '?' && (ch = getchar()) == '>') { break; } else { ch = getchar(); } } break; As has been hinted before you're not handling the EOF case. Files like: <?php class foo { function __construct() { echo 'foo'; }; }; Are perfectly valid php files and actually preferred for included files, rather then a terminating ?>, because one can start filling the output by trailing whitespace before EOF and thus not set any header() anymore. The above code will wait indefinitely for the next char or spin like mad if you're using non-blocking IO. You should really take the pointers from Jeffrey Goldberg and record states and decide based on the state, rather then inlined switch statements, if only for readability. You're also in trouble with <?xml, but that's an entirely different beast and you might actually be doing the right thing from your usage perspective. -- Mel
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906151857.45945.mel.flynn%2Bfbsd.questions>