Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active June 18, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamoCA/4f9951753f2fe3ed79ef5d7945d2f926 to your computer and use it in GitHub Desktop.
Save JamoCA/4f9951753f2fe3ed79ef5d7945d2f926 to your computer and use it in GitHub Desktop.
Test to determine if unicode entered in either email or URL is "valid" when using ColdFusion.
<h1>ColdFusion Unicode Email/URL Validation Test</h1>
<p><b>Adobe Bug ID:</b> <a href="https://tracker.adobe.com/#/view/CF-4204516" rel="nofollow noopener noreferrer">CF-4204516</a><br>
<b>TryCF:</b> <a href="https://www.trycf.com/gist/4f9951753f2fe3ed79ef5d7945d2f926" rel="nofollow noopener noreferrer">Link</a><br>
<b>GIST:</b> <a href="https://gist.github.com/JamoCA/4f9951753f2fe3ed79ef5d7945d2f926" rel="nofollow noopener noreferrer">Link</a></p>
<cfscript>
function testJavaURL(u){
var response = true;
var test = {};
var jURL = CreateObject("java", "java.net.URL");
try {
test = jURL.Init( javacast("string", arguments.u) );
} catch(any e) {
response = false;
}
return response;
}
</cfscript>
<cfset domains = [
"test.orβ“–",
"β„°π’³π’œβ„³π“Ÿβ„’β„°.π’žπ“žβ„³",
"dent.β„‘",
"norid.β„–"
]>
<cfoutput>
<p>NOTE: All of these domains function.<br>
More info a <a href="https://shkspr.mobi/blog/2018/11/domain-hacks-with-unusual-unicode-characters/" rel="nofollow noopener noreferrer">https://shkspr.mobi/blog/2018/11/domain-hacks-with-unusual-unicode-characters/</a></p>
<cfloop array="#domains#" index="thisDomain">
<hr>
<h2><a href="http://#thisDomain#/" rel="nofollow noopener noreferrer">http://#thisDomain#/</a></h2>
<p>isValid("email", "test@#thisDomain#") = #isValid("email", "test@#thisDomain#")#</p>
<p>isValid("url", "http://#thisDomain#/") = #isValid("url", "http://#thisDomain#/")#</p>
<p>testJavaURL("http://#thisDomain#/") = #testJavaURL("http://#thisDomain#/")#</p>
</cfloop>
</cfoutput>
<cfdump var="#Server#" label="Server Scope" expand="false">
<!---
6/18/2019: According to CF documentation for isValid("url"), The cfparam tag performs equivalent validation.
As a result, it's equivalently broken too. The following CFPARAM validation generates a CF error. (If an email
is passed with the same domain, it doesn't fail.)
<CFSET Form.TestEmail = "test@β„°π’³π’œβ„³π“Ÿβ„’β„°.π’žπ“žβ„³"><!--- email passes --->
<CFPARAM NAME="Form.TestEmail" DEFAULT="" TYPE="email">
<CFSET Form.TestURL = "https://β„°π’³π’œβ„³π“Ÿβ„’β„°.π’žπ“žβ„³/"><!--- URL fails --->
<CFPARAM NAME="Form.TestURL" DEFAULT="" TYPE="url">
--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment