Bug with fileExists() with an Application mapping of /

Description

If you declare an application mapping of "/" the behavior of fileExists() doesn't work as expected. The issue appears to be in how allowRealPath argument works.

I've attached a very simple use case that shows the problem.

When the Application.cfc has the following line:

this.mappings["/"] = getDirectoryFromPath(getCurrentTemplatePath());

The behavior of fileExists() is different before the onRequest life cycle and after the life cycle starts.

So, when this mapping exists, fileExists() will start returning false for files that do exist. You can use other file operations (i.e. fileRead()) without any issues.

If the example code in the /www root doesn't work, you can use Brad Wood's vagrant project to spin it up:

https://github.com/Ortus-Solutions/vagrant-centos-lucee

Just unzip this folder to a sibling of the folder vagrant-centos-lucee folder (per the Vagrant instructions).

Let me know if you have any questions. I have not tried this under Lucee 5 yet.

Environment

None

Attachments

1
  • 05 Mar 2016, 07:22 pm

Activity

Show:

Michael Offner 15 April 2016 at 07:30

this is unrelated to the / mapping, in every case of your example you are using first "expandPath("/index.cfm")", when you output the result of expandPath:

variable.outside = { "file" = expandPath("/index.cfm") , "default" = fileExists(expandPath("/index.cfm")) , "false" = fileExists(expandPath("/index.cfm"), false) , "true" = fileExists(expandPath("/index.cfm"), true) }; public any function onRequestStart(string targetPath){ variable.inside = { "file" = expandPath("/index.cfm") , "default" = fileExists(expandPath("/index.cfm")) , "false" = fileExists(expandPath("/index.cfm"), false) , "true" = fileExists(expandPath("/index.cfm"), true) }; writeDump(variables); abort; }

you will see that the path is always correct, at least in my enviroment

Fixed

Details

Assignee

Reporter

Priority

Labels

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 5 March 2016 at 19:28
Updated 31 January 2025 at 15:00
Resolved 15 April 2016 at 14:41