views:

182

answers:

1

I have an application in php that is intended for shared hosting. So, I am going to have a hard time always getting html tidy compiled, since the hosts will vary, and what they provide will vary.

Is it possible to just include the tidy executable in with my php application, and somehow, pipe html through that for cleaning?

I am just looking for a way to have html tidy bundled with my app, and not have to install or compile it after.

Thanks.

+1  A: 

Since the Tidy extension is a binding for the Tidy HTML clean and repair utility, I don't think this will work without compiling the Tidy utility on the destination server (not entirely sure though). If the utility is installed (but not the extension), you might be able to use Tidy through the command line, so you could try

 system( 'tidy -f errs.txt -m index.html' );

For shared hosts not offering Tidy, you could use HTMLPurifier as a standalone alternative. It's also somewhat more feature-rich than Tidy:

HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.

Gordon
Thanks for the tip about HTMLPurifier!
Nic Hubbard