Title:
CF10 & CF11 URL validation regular expression for 'isValid()' method are not in sync across CF10, CF11
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Joel Grimes / Joel Grimes ()
Created: 03/08/2017
Components: Core Runtime
Versions: 11.0,10.0
Failure Type: Data Loss
Found In Build/Fixed In Build: CF2016_Update3 / 302221
Priority/Frequency: Normal / Most users will encounter
Locale/System: English / Windows 7
Vote Count: 1
Inconsistent behavior across CF 10 / CF 11 and CF 2016 needs to be streamlined.
Method:
Run the below script in CF 10, CF 11, CF 2016,
<cfscript>
/* 5/5/2014 http://www.cflib.org/udf/IsURL
A quick way to test if a string is a URL
@param stringToCheck The string to check.
@return Returns a boolean.
@author Nathan Dintenfass (nathan@changemedia.com)
@version 1, November 22, 2001
@version 2, August 8, 2010 James Moberg (based on http://daringfireball.net/2010/07/improved_regex_for_matching_urls )
@version 3, May 5, 2014 https://gist.github.com/gruber/8891611 */
function isURL(stringToCheck){
var URLRegEx = "(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'"".,<>?«»“”‘’]))";
return isValid("regex", stringToCheck, URLRegex);
}
</cfscript>
<CFSET SampleURL = "https://1drv.ms/w/s!AxMFbFZhZt7hg8NqJw9IieGxPB5yff">
<!--- NOTE: URL modified as to not link to actual valid document, but URL structure is "valid". --->
<p>Identified & publicized on 1/24/2017. CF10.0.22+301868 & 11.0.11+301867 fail to identify a OneDrive URL as valid. (NOTE: Lucee 4.5 & 5 both return the correct result.)
(Tested using Windows & CommandBox and TryCF http://trycf.com/editor/gist/af153f0b1693672e605ad1ea7d7807aa)</p>
<p>CF10 Core Support ends on 5/16/2017. Will Adobe add this CF2016 BIF update to CF10 before core support ends?
(My recommendation is to avoid using Adobe's blackbox built-in functions (BIFs) until they post unit tests demonstrating
that they've been fully tested.)</p>
<hr>
<CFOUTPUT>
ColdFusion Version: #Server.ColdFusion.ProductVersion#<br>
Built-in Function isValid("url") = #isValid("url", SampleURL)#<br>
UDF isURL() = #isURL(SampleURL)#
</CFOUTPUT>
More info here:
https://gamesover2600.tumblr.com/post/155123452479/coldfusion-validation-of-numbers-wextra-hidden
https://gamesover2600.tumblr.com/post/156313357099/isvalidurl-has-changed-in-coldfusion-2016
Attachments:
Comments: