tracker issue : CF-4204293

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

expandPath incorrectly expands absolute paths

| View in Tracker

Status/Resolution/Reason: To Test//Fixed

Reporter/Name(from Bugbase): Ryan P. / ()

Created: 05/07/2019

Components: Language, Functions

Versions: 2016

Failure Type: Conflict With Docs

Found In Build/Fixed In Build: 2016,0,10,314028 /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Windows 10

Vote Count: 1

Problem Description:
According to the documentation for expandPath, it should be able to take in an absolute path and correctly expand it while no direct example is given for this use case it seems reasonable to expect it to return the same path with maybe the slashes corrected for the current OS. Instead it will take the path and append it to the end of the path to the current coldfusion file.

Steps to Reproduce:
writeOutput(expandPath("C:\path\to\file\file.txt"));

Actual Result:
C:\path\to\cfm\file\C:\path\to\file\file.txt

Expected Result:
C:\path\to\file\file.txt

Any Workarounds:
You can workaround this by only attempting to expand the path if it is a relative path. The path can be determined to be relative by calling getDirectoryFromPath on it and the negating the result of directoryExists on the prior results. !directoryExists(getDirectoryFromPath("\path\to\file\file.txt"))

Attachments:

Comments:

Hello Ryan, I looked into the issue and seems like expandPath doesn't support absolute path as of now. I also found that there is no single way to handle the absolute path for all platforms. So, what I propose is -  we will expose a new Built in function expandPath(String path, boolean isAbsolutePath)  , if the path is absolute then {color:#172b4d}isAbsolutePath{color} needs to be passed as true else false. Please let me know your views.
Comment by Vijay M.
30908 | June 12, 2019 07:19:30 AM GMT
If we are checking to see if a path is absolute in order to pass in the boolean value then we have already done the work needed to bypass using the ExpandPath function anyway, so the proposed solution seems like a waste of time. java.nio.Path contains an isAbsolute method, would it not work?
Comment by Geoff C.
30919 | June 14, 2019 01:40:38 AM GMT