Last active
June 18, 2019 13:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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