Validating HTML/XHTML behind a firewall

July 30, 2003

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#">

2 people found this page useful, what do you think?

Post a Comment


Spell Checker by Foundeo

Recent Entries


did you hack my cf?