Title:
ExpandPath Returns Incorrect Path When Used with Mappings in Application.cfc
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Rob Bilson / Rob Bilson (Rob Bilson)
Created: 06/30/2014
Components: General Server
Versions: 11.0
Failure Type:
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Major / Most users will encounter
Locale/System: ALL / Mac 10 All
Vote Count: 3
Behavior has changed between ColdFusion 9/10 and ColdFusion 11 so that the expandPath() funcion returns an incorrect path to files using ColdFusion Mappings when used within Application.cfc or any component extended by Application.CFC.
Test case:
/
/foo
foo.cfc
/config
config.xml
/wwwroot
/cf11_mapping_bug
Application.cfc
test.cfm
Create a Mapping in the ColdFusion administrator for /foo, pointing to the /foo directory you just created.
Here are the files you'll need:
<!--- foo.cfc --->
<cfcomponent output="true">
<cfparam name="xmlConfigFile" default="#expandPath('/foo/config/config.xml')#" />
<cfoutput>
In foo.cfc <br />
#xmlConfigFile# <br />
</cfoutput>
</cfcomponent>
<!--- Application.cfc --->
<cfcomponent extends="foo.foo" output="true">
<cfset xmlConfigFile = expandPath('/foo/config/config.xml') />
<cfoutput>
In Application.cfc <br />
#xmlConfigFile# <br />
</cfoutput>
</cfcomponent>
<!--- test.cfm --->
<cfoutput>
In test.cfm <br />
#expandPath('/foo/config/config.xml')# <br />
</cfoutput>
<!-- config.xml -->
<foo />
Executing the code on ColdFusion 9/10 results in the following output:
In foo.cfc
/Users/rbils/Sites/localhost/foo/config/config.xml
In Application.cfc
/Users/rbils/Sites/localhost/foo/config/config.xml
In test.cfm
/Users/rbils/Sites/localhost/foo/config/config.xml
Executing the same code in ColdFusion 11 results in the following:
In foo.cfc
/Users/rbils/Sites/localhost/wwwroot/foo/config/config.xml
In Application.cfc
/Users/rbils/Sites/localhost/wwwroot/foo/config/config.xml
In test.cfm
/Users/rbils/Sites/localhost/foo/config/config.xml
As you can see, expandPath when used in Application.cfc or a component extended by Application.cfc results in the mapped path being incorrectly returned. We expect to see:
/Users/rbils/Sites/localhost/foo/config/config.xml
But the bug is causing the mapping to be ignored and instead appended to the base path like so:
/Users/rbils/Sites/localhost/wwwroot/foo/config/config.xml
In the real world, this is breaking all of our mach-ii apps, and requires code changes to work around the problem by providing absolute paths.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3783403
External Customer Info:
External Company:
External Customer Name: Rob Brooks-Bilson
External Customer Email:
External Test Config: My Hardware and Environment details: Tested on ColdFusionn 9, 10, and 11 on Windows and OS X.
Attachments:
Comments: