tracker issue : CF-3916425

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: CF rewrites file://host as file:////host

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 01/06/2015

Components: File Management

Versions: 11.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: CF11_Final / CF10 Update16

Priority/Frequency: Normal / Some users will encounter

Locale/System: ALL / Platforms All

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on February 16, 2019 using build 2016.0.01.298513
CF rewrites file://host as file:////host. This causes exceptions and unexpected results (and potential date corruption due to directoryList() and <cfdirectory action="list" returning an incorrect number of rows).

Steps to reproduce:
1) Create C:\ticket3863993 and share it as ticket3863993
2) Create C:\ticket3863993\myfile.txt
3) Run the following code:

<cfscript>
  //These fail or return incorrect results
  writeDump(directoryExists("file://localhost/C:/ticket3863993"));//Returns NO
  q = directoryList("file://localhost/ticket3863993", true, "query");
  writeDump(q);//Directory column contains file:////localhost/ticket3863993/ instead of file://localhost/ticket3863993/
  q = directoryList("file://localhost/C:/ticket3863993", true, "query");//Throws exception: The specified directory file:////localhost/C:/ticket3863993 does not exist. 
  writeDump(q);
  //These succeed
  writeDump(directoryExists("file:///C:/ticket3863993"));//Returns YES
  q = directoryList("file:///C:/ticket3863993", true, "query");
  writeDump(q);
</cfscript>
<!--- These fail or return incorrect results --->
<cfdirectory action="list" name="q" directory="file://localhost/ticket3863993">
<cfdump var="#q#"><!--- Directory column contains file:////localhost/ticket3863993/ instead of file://localhost/ticket3863993/ --->
<cfdirectory action="list" name="q" directory="file://localhost/C:/ticket3863993">
<cfdump var="#q#"><!--- Returns 0 results --->
<!--- These succeed --->
<cfdirectory action="list" name="q" directory="file://localhost/ticket3863993">
<cfdump var="#q#">

Per http://en.wikipedia.org/wiki/File_URI_scheme, a file URI takes the form of file://host/path and host is treated as "localhost" if omitted. CF is incorrectly rewriting file://host as file:////host.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3916425

External Customer Info:
External Company:  
External Customer Name: itisdesign
External Customer Email:

Attachments:

Comments:

"date corruption" should've been "data corruption"
Comment by External U.
9118 | January 06, 2015 02:36:22 AM GMT
The issue here was difference of behavior for the same path when directory list was invoked from tag and from function. Now in both cases empty file list will be returned(keeping it consistent with previous CF behavior) in case directory cannot be located from the given URI. Also the URI in the result which may contain extra // will not create any issue when used with file/directory tags/ functions. ColdFusion does not change them they are same as the underlying file object returns. (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
9119 | January 28, 2015 11:58:07 PM GMT
Hi Sandeep, The second issue is directoryExists("file://localhost/C:/ticketCF-3863993")); should return YES. Per the File URI Scheme (http://en.wikipedia.org/wiki/File_URI_scheme): "A file URI takes the form of file://host/path" So, CF should correctly locate the directory even when URI specifies host. Thanks!, -Aaron
Comment by External U.
9120 | January 29, 2015 04:09:10 AM GMT
Hi Aaron, I tried the same URI directly in Java. the URI with format file://localhost/C:/ticketCF-3863993 doest not find the valid file and file exists return false only ffor this URI. Rest all URI return correct result. It seems that URI format is not considered as valid. (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
9121 | January 29, 2015 06:21:01 AM GMT
Hi Sandeep, No problem then. If Java doesn't consider it valid, then I suppose it is okay if CF doesn't consider it valid. Thank you for checking in Java! Thanks, -Aaron
Comment by External U.
9122 | January 30, 2015 04:35:13 AM GMT
The fix for this bug is available in the pre-release build of ColdFusion 10 Update 16
Comment by Suchika S.
9123 | February 20, 2015 10:07:06 AM GMT
This bug has been raised against CF11, but is marked as fixed in CF10 u16 - does that mean it is ALSO fixed in CF11 u5, or not?
Comment by External U.
9124 | February 26, 2015 06:13:34 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). directoryList() now correctly returns a 0-row query, instead of exception, when the directory cannot be found via the given URI. This matches <cfdirectory action="list"> behavior, as noted by Adobe above. Note: This ticket says this issue was fixed in CF10 Update 6. And someone asked, in the previous comment, if this was also fixed in CF11 Update 5 (which was released on the same day as CF10 Update 6). Since this ticket wasn't included in CF11 Update 5's Issues Fixed list, but was listed in CF2016 Final's Issues Fixed list, I'm guessing CF11's fix came in a later update that was released while CF2016 was in alpha/beta. I did confirm CF11 Update 7 (build 11.0.07.296330) has the correct behavior. Thanks!, -Aaron
Comment by Aaron N.
30276 | February 16, 2019 06:16:39 AM GMT