Pete Freitag Pete Freitag

Validating HTML/XHTML behind a firewall


Someone asked the question on the evolt mailing list about validating XHTML behind a firewall. The most popular way to validate XHTML is using the w3c HTML validator, however the only options are to enter a url, or to upload a file. That can be cumbersome, so steve clay wrote a handy php script that crawls a url and uploads the file then displays the results. I ported his script to ColdFusion below. It works great in CFMX, but there are issues in CF5 (cfhttp is url encoding the charset). You might also want to wrap a html tags around this code.

Ported To ColdFusion by Pete Freitag
Based on
License: (GPL) 
<form action="#CGI.SCRIPT_NAME#" method="post">
	<label for="location">Validate Local URL:</label>
	<input type="text" name="location" value="http://#CGI.SERVER_NAME#/" />
	<input type="submit" value="Validate" />

<cfif IsDefined("form.location")>
	<cfset tempFile = GetTempFile(GetTempDirectory(), "validatorFile")>
	<cfhttp url="#form.location#" method="get" path="#GetTempDirectory()#"
		file="#GetFileFromPath(tempFile)#" />
	<cfhttp url="" method="post" resolveurl="yes">
		<cfhttpparam type="formfield" name="charset" value="UTF-8">
		<cfhttpparam type="formfield" name="doctype" value="Inline">
		<cfhttpparam type="formfield" name="ss" value="1"> 
		<cfhttpparam type="formfield" name="verbose" value="1">
		<cfhttpparam type="file" file="#tempFile#" name="uploaded_file">
	<cffile action="delete" file="#tempFile#">

Like this? Follow me ↯

Validating HTML/XHTML behind a firewall was first published on July 30, 2003.

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.